/// <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="isShow"></param> protected void SetBedRangeStatus(bool isShow) { //打开所有床位的范围显示 BuildBedCpt[] listBed = InnBuildHandler.Instance.builderForFurniture.GetAllBed(); if (!CheckUtil.ArrayIsNull(listBed)) { for (int i = 0; i < listBed.Length; i++) { BuildBedCpt buildBed = listBed[i]; buildBed.ShowRange(isShow); } } }
public void SetIcon(long achId, long[] preIds, string iconKey, string preData) { GameDataBean gameData = GameDataHandler.Instance.manager.GetGameData(); bool isAllPre = PreTypeEnumTools.CheckIsAllPre(gameData, gameData.userCharacter, preData, out string reason); if (ivIcon == null || ivBackground == null) { return; } //检测是否拥有该成就 bool hasAch = gameData.GetAchievementData().CheckHasAchievement(achId); if (hasAch) { SetAchStatus(AchievementStatusEnum.Completed); return; } //检测前置成就 if (CheckUtil.ArrayIsNull(preIds)) { //检测是否符合条件 if (isAllPre) { SetAchStatus(AchievementStatusEnum.ToBeConfirmed); } else { SetAchStatus(AchievementStatusEnum.Processing); } } else { bool hasPre = gameData.GetAchievementData().CheckHasAchievement(preIds); if (hasPre) { //检测是否符合条件 if (isAllPre) { SetAchStatus(AchievementStatusEnum.ToBeConfirmed); } else { SetAchStatus(AchievementStatusEnum.Processing); } } else { SetAchStatus(AchievementStatusEnum.UnKnown); } } }
/// <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> /// string 拆分成指定枚举 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data"></param> /// <param name="substring"></param> /// <returns></returns> public static T[] SplitBySubstringForArrayEnum <T>(string data, char substring) { if (CheckUtil.StringIsNull(data)) { return(new T[0]); } string[] splitData = data.Split(new char[] { substring }, StringSplitOptions.RemoveEmptyEntries); if (CheckUtil.ArrayIsNull(splitData)) { return(new T[0]); } T[] listData = new T[splitData.Length]; for (int i = 0; i < splitData.Length; i++) { if (CheckUtil.StringIsNull(splitData[i])) { } else { listData[i] = EnumUtil.GetEnum <T>(splitData[i]); } } return(listData); }