Esempio n. 1
0
        public static void initialize_particle(List <Particle> p, int particle_template, float duration, double angle, int start_x, int start_y, int pbounces, bool allow_pass, Display d)
        {
            //angle is passed in degrees, need to convert it to radions
            //angle = Math.PI * (angle / 180.0);
            p.Sort((x, y) => y.enabled.CompareTo(x.enabled));
            int use_id = -1;

            for (int x = 0; x < p.Count; x++)
            {
                if (p[x].enabled == false)
                {
                    use_id = x;
                    x      = p.Count + 1;
                }
            }
            if (use_id == -1 && p.Count < 1500)
            {
                p.Add(new Particle());
                use_id = p.Count - 1;
            }
            if (use_id != -1)
            {
                p[use_id].enabled      = true;
                p[use_id].particle_id  = particle_template;
                p[use_id].sec_run      = duration;
                p[use_id].world_loc.X  = start_x;
                p[use_id].world_loc.Y  = start_y;
                p[use_id].bounces      = pbounces;
                p[use_id].orient_angle = (float)angle;
                p[use_id].orient       = true;
                p[use_id].pass_through = allow_pass;
                p[use_id].inertia.X    = (float)Math.Cos(angle) * Exilania.particle_manager.particles[particle_template].speed;
                p[use_id].inertia.Y    = (float)Math.Sin(angle) * Exilania.particle_manager.particles[particle_template].speed;
                p[use_id].center       = new Vector2(Exilania.particle_manager.particles[p[use_id].particle_id].image.Width / 2,
                                                     Exilania.particle_manager.particles[p[use_id].particle_id].image.Height / 2);
                p[use_id].orient_angle = (float)Math.Atan2(p[use_id].inertia.Y, p[use_id].inertia.X);
            }
        }