Пример #1
0
        private List <Point[]> CalculateContiniousPath()
        {
            const float MAX_DISTANCE = 100;
            const float PATH_STEP    = 1f;

            var objects = world.Objects.Select(x => x.Clone()).ToList();
            //objects.Add(launchObject);

            var objectsPath = new Dictionary <GravityObject, List <Point> >();

            for (var i = 0f; i < MAX_DISTANCE; i += PATH_STEP)
            {
                foreach (var obj in objects)
                {
                    if (!objectsPath.ContainsKey(obj))
                    {
                        objectsPath.Add(obj, new List <Point>());
                    }

                    objectsPath[obj].Add(new Point((int)obj.Position.X, (int)obj.Position.Y));

                    PhysicsController.CalcStepFor(obj, objects, PATH_STEP);

                    obj.Position += obj.Velocity * PATH_STEP;
                }
            }

            return(objectsPath.Select(x => x.Value.ToArray()).ToList());
        }
Пример #2
0
        private Point[] CalculatePath(Point position)
        {
            const float MAX_DISTANCE = 1000;
            const float PATH_STEP    = 5f;

            var path = new List <Point>();

            launchObject.Position   = new Vector2(position.X, position.Y);
            launchObject.Velocity.X = launchSpeed;

            for (var i = 0f; i < MAX_DISTANCE; i += PATH_STEP)
            {
                path.Add(new Point((int)launchObject.Position.X, (int)launchObject.Position.Y));

                PhysicsController.CalcStepFor(launchObject, world.Objects, PATH_STEP);

                launchObject.Position += launchObject.Velocity * PATH_STEP;
            }

            launchObject.Position = new Vector2();
            launchObject.Velocity = new Vector2();

            return(path.ToArray());
        }