/// <summary> /// 拆分并随机获取一个数值 /// </summary> /// <param name="data"></param> /// <param name="substring"></param> /// <returns></returns> public static long SplitAndRandomForLong(string data, char substring) { long[] arrayData = SplitBySubstringForArrayLong(data, substring); if (CheckUtil.ArrayIsNull(arrayData)) { return(0); } return(RandomUtil.GetRandomDataByArray(arrayData)); }
/// <summary> /// 获取随机道具的奖励详情 /// </summary> /// <param name="data"></param> /// <param name="iconDataManager"></param> /// <param name="gameItemsManager"></param> /// <returns></returns> private static RewardTypeBean GetRewardDetailsForRandomItems(RewardTypeBean data) { long[] listItemsData = StringUtil.SplitBySubstringForArrayLong(data.data, ','); long randomItemsId = RandomUtil.GetRandomDataByArray(listItemsData); ItemsInfoBean itemsInfo = GameItemsHandler.Instance.manager.GetItemsById(randomItemsId); data.rewardDescribe = itemsInfo.name; data.rewardNumber = 1; data.rewardId = randomItemsId; data.rewardDescribe += (" x" + data.rewardNumber); data.spRewardIcon = GeneralEnumTools.GetGeneralSprite(itemsInfo, true); return(data); }
/// <summary> /// 开始射击目标 /// </summary> /// <returns></returns> public IEnumerator StartLaunch() { while (true) { //获取所有发射器 List <MiniGameBarrageEjectorCpt> listEjector = miniGameBuilder.GetEjector(); if (!CheckUtil.ListIsNull(listEjector)) { foreach (MiniGameBarrageEjectorCpt itemEjector in listEjector) { //获取所有的目标 List <NpcAIMiniGameBarrageCpt> listPlayer = miniGameBuilder.GetPlayerList(); //随机获取一个NPC NpcAIMiniGameBarrageCpt npcCpt = RandomUtil.GetRandomDataByList(listPlayer); Vector3 launchTarget = Vector3.zero; if (npcCpt != null) { launchTarget = npcCpt.transform.position; } //获取发射类型 if (CheckUtil.ArrayIsNull(miniGameData.launchTypes)) { miniGameData.launchTypes = new MiniGameBarrageEjectorCpt.LaunchTypeEnum[] { MiniGameBarrageEjectorCpt.LaunchTypeEnum.Single }; } MiniGameBarrageEjectorCpt.LaunchTypeEnum launchType = RandomUtil.GetRandomDataByArray(miniGameData.launchTypes); itemEjector.StartLaunch(launchType, miniGameData.bulletType, launchTarget, miniGameData.launchSpeed); } } //发射间隔时间 float launchIntervalTime = miniGameData.launchInterval; if (launchIntervalTime < 0.1f) { launchIntervalTime = 0.1f; } yield return(new WaitForSeconds(launchIntervalTime)); } }
/// <summary> /// 意图-等待回复 /// </summary> protected void SetIntentForWaitingForReply() { if (teamRank == 0) { long talk_ids = RandomUtil.GetRandomDataByArray(teamData.GetTalkIds()); if (talk_ids == 0) { SetTeamIntent(RascalIntentEnum.Leave); return; } bool isTrigger = GameEventHandler.Instance.EventTriggerForTalkByRascal(this, talk_ids); if (isTrigger) { GameEventHandler.Instance.RegisterNotifyForEvent(NotifyForEvent); } else { //如果没有触发事件 则全体离开 SetTeamIntent(RascalIntentEnum.Leave); } } }
public List <CharacterBean> GetCharacterDataByInfiniteTowersLayer(long layer) { List <CharacterBean> listData = new List <CharacterBean>(); if (layer % 10 == 0) { //Boss层数 string bossTeamMembers = ""; switch (layer) { case 10: case 20: case 30: GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel1, out bossTeamMembers); //bossTeamMembers = "7400011"; break; case 40: case 50: case 60: GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel2, out bossTeamMembers); break; case 70: case 80: case 90: GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel3, out bossTeamMembers); break; case 100: case 110: case 120: GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel4, out bossTeamMembers); break; default: GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel1, out string level1); GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel2, out string level2); GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel2, out string level3); GameCommonInfo.baseDataController.GetBaseData(BaseDataTypeEnum.InfiniteTowersBossForLevel2, out string level4); bossTeamMembers = level1 + "|" + level2 + "|" + level3 + "|" + level4; break; } string[] randomBossTeam = StringUtil.SplitBySubstringForArrayStr(bossTeamMembers, '|'); string bossTeamStr = RandomUtil.GetRandomDataByArray(randomBossTeam); long bossTeamId = StringUtil.SplitAndRandomForLong(bossTeamStr, ','); NpcTeamBean bossTeamData = NpcTeamHandler.Instance.manager.GetInfiniteTowerBossTeam(bossTeamId); long[] membersIds = bossTeamData.GetTeamMembersId(); long[] bossId = bossTeamData.GetTeamLeaderId(); foreach (long itemMemberId in membersIds) { CharacterBean memberData = NpcInfoHandler.Instance.manager.GetCharacterDataById(itemMemberId); if (memberData != null) { memberData.body.CreateRandomBody(); listData.Add(memberData); } } foreach (long itemBossId in bossId) { CharacterBean bossData = NpcInfoHandler.Instance.manager.GetCharacterDataById(itemBossId); if (bossData != null) { //bossData.body.CreateRandomBody(characterBodyManager); listData.Insert((membersIds.Length / 2), bossData); } } } else { //普通层数 List <CharacterBean> listCharacter = NpcInfoHandler.Instance.manager.GetCharacterDataByType(NpcTypeEnum.GuestTeam); List <CharacterBean> listTempCharacter = new List <CharacterBean>(); if (!CheckUtil.ListIsNull(listCharacter)) { for (int i = 0; i < listCharacter.Count; i++) { CharacterBean itemCharacter = listCharacter[i]; //判断层数 int level = int.Parse(itemCharacter.npcInfoData.remark); int layerLevel = Mathf.FloorToInt(layer / 10f); if (layerLevel <= 15 && level == layerLevel) { listTempCharacter.Add(itemCharacter); } } } CharacterBean baseCharacterData = null; if (listTempCharacter.Count == 0) { baseCharacterData = RandomUtil.GetRandomDataByList(listCharacter); } else { baseCharacterData = RandomUtil.GetRandomDataByList(listTempCharacter); } //随机生成身体数据 CharacterBean characterOne = ClassUtil.DeepCopyByReflect(baseCharacterData); characterOne.body.CreateRandomBody(); listData.Add(characterOne); CharacterBean characterTwo = ClassUtil.DeepCopyByReflect(baseCharacterData); characterTwo.body.CreateRandomBody(); listData.Add(characterTwo); CharacterBean characterThree = ClassUtil.DeepCopyByReflect(baseCharacterData); characterThree.body.CreateRandomBody(); listData.Add(characterThree); } return(listData); }
/// <summary> /// 获取烹饪游戏数据 /// </summary> /// <param name="itemPreData"></param> /// <param name="miniGameData"></param> private static void GetMiniGameDataForCook(PreTypeForMiniGameBean itemPreData, MiniGameBaseBean miniGameData) { if (miniGameData.gameType != MiniGameEnum.Cooking) { return; } MiniGameCookingBean miniGameCooking = (MiniGameCookingBean)miniGameData; //审核人员 List <CharacterBean> listAuditData = new List <CharacterBean>(); //主持人 List <CharacterBean> listCompereData = new List <CharacterBean>(); switch (itemPreData.dataType) { case PreTypeForMiniGameEnum.CookingForScore: miniGameData.winScore = int.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.CookingForStoryStartId: miniGameCooking.storyGameStartId = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.CookingForStoryAuditId: miniGameCooking.storyGameAuditId = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.CookingForAuditCharacter: long[] auditIds = StringUtil.SplitBySubstringForArrayLong(itemPreData.data, ','); listAuditData = NpcInfoHandler.Instance.manager.GetCharacterDataByIds(auditIds); //评审人员只有5位 listAuditData = RandomUtil.GetRandomDataByListForNumberNR(listAuditData, 5); //如果评审人员不够 就随机增加小镇人员 if (listAuditData.Count < 5) { int tempNumber = 5 - listAuditData.Count; List <CharacterBean> listTempCharacterData = NpcInfoHandler.Instance.manager.GetCharacterDataByType(NpcTypeEnum.Town); listAuditData.AddRange(RandomUtil.GetRandomDataByListForNumberNR(listTempCharacterData, tempNumber)); } break; case PreTypeForMiniGameEnum.CookingForCompereCharacter: long[] compereIds = StringUtil.SplitBySubstringForArrayLong(itemPreData.data, ','); listCompereData = NpcInfoHandler.Instance.manager.GetCharacterDataByIds(compereIds); break; case PreTypeForMiniGameEnum.CookingForThemeLevel: int[] themeLevels = StringUtil.SplitBySubstringForArrayInt(itemPreData.data, ','); miniGameCooking.cookingThemeLevel = RandomUtil.GetRandomDataByArray(themeLevels); break; case PreTypeForMiniGameEnum.CookingForThemeId: miniGameCooking.cookingThemeId = long.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.CookingForButtonNumber: miniGameCooking.cookButtonNumber = int.Parse(itemPreData.data); break; case PreTypeForMiniGameEnum.CookingForWinRank: miniGameCooking.winRank = int.Parse(itemPreData.data); break; } miniGameCooking.InitData(null, null, listAuditData, listCompereData); }