public PlatformCauseOfDestroy.CauseOfDestroy GetRandomPlatformCauseOfDestroy( PlatformMovingTypes[] platformMovingTypes, IPlatformMotionConfig[] platformMotionConfigs, PlatformCreatingPlace platformCreatingPlace) { HashSet <PlatformCauseOfDestroy.CauseOfDestroy> platformCauseOfDestroys = new HashSet <PlatformCauseOfDestroy.CauseOfDestroy>(); if (platformCreatingPlace == PlatformCreatingPlace.InRandomArea) { platformCauseOfDestroys.Add(PlatformCauseOfDestroy.CauseOfDestroy.NoLifeTime); } bool isPlatformVerticalMotion = platformMovingTypes.Contains(PlatformMovingTypes.VerticalMotion); bool isPlatformCircularMotion = platformMovingTypes.Contains(PlatformMovingTypes.CircularMotion); if (isPlatformVerticalMotion) { VerticalMotionConfig verticalMotionConfig = (VerticalMotionConfig)platformMotionConfigs.ToList().Find(x => x is VerticalMotionConfig); platformCauseOfDestroys.Add(GetPlatformCauseOfDestroyByVerticalMotionConfig(verticalMotionConfig.Value)); } else if (!isPlatformVerticalMotion && isPlatformCircularMotion) { platformCauseOfDestroys.Add(PlatformCauseOfDestroy.CauseOfDestroy.AsTimePasses); } return(Randomizer.GetRandomItem(platformCauseOfDestroys.ToArray())); }
public PlatformCreatingPlace GetRandomPlatformCreatingPlace(PlatformMovingTypes[] platformMovingTypes, IPlatformMotionConfig[] platformMovingTypeConfigs) { HashSet <PlatformCreatingPlace> availablePlatformCreatingPlaces = new HashSet <PlatformCreatingPlace> { PlatformCreatingPlace.InRandomArea }; if (platformMovingTypes.Contains(PlatformMovingTypes.VerticalMotion)) { VerticalMotionConfig verticalMotionConfig = (VerticalMotionConfig)platformMovingTypeConfigs.ToList().Find(x => x is VerticalMotionConfig); switch (verticalMotionConfig.Value) { case VerticalMotionConfig.MotionConfigs.Up: availablePlatformCreatingPlaces.Add(PlatformCreatingPlace.InCentre); break; case VerticalMotionConfig.MotionConfigs.Down: availablePlatformCreatingPlaces.Add(PlatformCreatingPlace.InHighestArea); break; case VerticalMotionConfig.MotionConfigs.Random: availablePlatformCreatingPlaces.Add(PlatformCreatingPlace.InRandomArea); break; default: throw new System.Exception($"{verticalMotionConfig.Value} is unknown MotionConfig!"); } } return(Randomizer.GetRandomItem(availablePlatformCreatingPlaces.ToArray())); }
private void SetMotionConfigsAndGetCauseOfDestroy(GameObject createdPlatform, out PlatformCauseOfDestroy.CauseOfDestroy platformCausesOfDestroy) { // CauseOfDestroy в некоторых случаях может задаваться не при общей настройке правил генерации, а при определении правил движения вертикальной платформы. var movingTypeConfigs = PlatformGeneratorConfigs.PlatformConfigs.MovingTypeConfigs; platformCausesOfDestroy = PlatformGeneratorConfigs.PlatformConfigs.CauseOfDestroy; if (createdPlatform.TryGetComponent(out VerticalMotion verticalMotion)) { VerticalMotionConfig verticalMotionConfig = (VerticalMotionConfig)movingTypeConfigs.ToList().Find(x => x is VerticalMotionConfig); VerticalMotionConfig.MotionConfigs config = verticalMotionConfig.Value != VerticalMotionConfig.MotionConfigs.Random ? verticalMotionConfig.Value : verticalMotionConfig.GetConcreteRandomEnumValue(); if (platformCausesOfDestroy == PlatformCauseOfDestroy.CauseOfDestroy.LateInitialization) { platformCausesOfDestroy = new PlatformConfigsData().GetPlatformCauseOfDestroyByVerticalMotionConfig(config); if (platformCausesOfDestroy == PlatformCauseOfDestroy.CauseOfDestroy.LateInitialization) { Debug.LogError("VerticalMotionConfigs shouldn't be Random!"); } } verticalMotion.SetMotionConfigs(config); } if (createdPlatform.TryGetComponent(out CircularMotion circularMotion)) { CircularMotionConfig circularMotionConfig = (CircularMotionConfig)movingTypeConfigs.ToList().Find(x => x is CircularMotionConfig); CircularMotionConfig.MotionConfigs config = circularMotionConfig.Value != CircularMotionConfig.MotionConfigs.Random ? circularMotionConfig.Value : circularMotionConfig.GetConcreteRandomEnumValue(); circularMotion.SetMotionConfigs(config); } }