private PhysicalObject[] GenerateObstacles(int count) { var objs = new List <PhysicalObject>(); for (int i = 0; i < count; i++) { OcTree tree = null; PhysicalObject obj = null; for (int n = 0; n < MaxTryCount; n++) { obj = ObstacleFactory.MakeObstacle(); obj.Position = GetPointInCircle(WorldScale * _config.ObstacleRange); if (GameMath.MathF.Abs(obj.Position.X) > WorldScale - 2f) { continue; } if (GameMath.MathF.Abs(obj.Position.Y) > WorldScale - 2f) { continue; } tree = new OcTree(_worldZone, objs, false); if (tree != null && !tree.Intersect(obj.Position, obj.Radius + ObstacleFactory.SpaceBetween)) { break; } } objs.Add(obj); } return(objs.ToArray()); }
void Start() { obFac = GetComponent <ObstacleFactory>(); startButton.onClick.AddListener(StartGame); }