public void SetMotionConfigs(CircularMotionConfig.MotionConfigs circularMotionConfigs) { switch (circularMotionConfigs) { case CircularMotionConfig.MotionConfigs.Left: direction = 1; break; case CircularMotionConfig.MotionConfigs.Right: direction = -1; break; default: throw new Exception($"{circularMotionConfigs} is unknown motionConfig!"); } velocityMultiplier = Random.Range(minVelocityMultiplier, maxVelocityMultiplier); }
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); } }