Ejemplo n.º 1
0
        public IObservable <KeyValuePair <DateTime, Tuple <double, double>[]> > Run(IObservable <KeyValuePair <DateTime, double?> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            return(meas.IncrementalTimeOffsets().Select(_ =>
            {
                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, _.Key.Item2);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    _.Key.Item1, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                if (_.Value != null)
                {
                    FilterSharp.Update(new Point(0, (double)_.Value));
                }


                return prd;
            }));
        }
Ejemplo n.º 2
0
        public IEnumerable <KeyValuePair <DateTime, Tuple <double, double>[]> > BatchRun1D(IEnumerable <KeyValuePair <DateTime, Point> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            DateTime dt = meas.First().Key;

            foreach (var m in meas)
            {
                TimeSpan ticks = (m.Key - dt);

                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, ticks);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    m.Key, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                if (m.Value != default(Point))
                {
                    FilterSharp.Update(m.Value);
                }

                dt = m.Key;

                yield return(prd);
            }
            ;
        }
Ejemplo n.º 3
0
        public IEnumerable <KeyValuePair <DateTime, Tuple <double, double>[]> > BatchRun(IEnumerable <KeyValuePair <DateTime, double> > meas)
        {
            ParticleFilterSharp1D FilterSharp = new ParticleFilterSharp1D();


            FilterSharp.Particles = ParticleFactory.BuildSwarm(N, new int[] { min, max }).ToList();


            DateTime dt = meas.First().Key;

            return(meas.Select(_ =>
            {
                TimeSpan ticks = (_.Key - dt);

                // move based on last measurement
                FilterSharp.Predict(EffectiveCountMinRatio, ticks);

                var prd = new KeyValuePair <DateTime, Tuple <double, double>[]>(
                    dt, FilterSharp.Particles.Select(__ => Tuple.Create(__.Y, __.Weight)).ToArray());


                // incorporate measurement
                FilterSharp.Update(new Point(0, _.Value));

                dt = _.Key;

                return prd;
            }));
        }
Ejemplo n.º 4
0
        public void ParticleDirectionalClassCountDirectional()
        {
            DirectionParticle dir = ParticleFactory
                                    .Get(ParticleType.Direction) as DirectionParticle;

            Assert.AreEqual(dir.CurrentGameObjects().Count, 3);
        }
Ejemplo n.º 5
0
        public void ParticleCollisionClassCountCollision()
        {
            CollisionParticle col = ParticleFactory
                                    .Get(ParticleType.Collision) as CollisionParticle;

            Assert.AreEqual(col.CurrentGameObjects().Count, 1);
        }
Ejemplo n.º 6
0
    public void Execute(Transform position)
    {
        Debug.Log("Sea mine fired!");

        AmmoFactory.CreateSeaMineShot(position, Data);
        ParticleFactory.CreateShotSmoke(position);
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rabbit" /> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="drawOrder">The draw order.</param>
        /// <param name="assetsContainer">The assets container</param>
        public Rabbit(Vector2 position, float drawOrder, AssetsContainer assetsContainer)
        {
            this.entity = new Entity()
                          .AddComponent(new Transform2D()
            {
                Origin    = Vector2.Center,
                X         = position.X,
                Y         = position.Y,
                DrawOrder = drawOrder,
                XScale    = 0.8f,
                YScale    = 0.8f,
            })
                          .AddComponent(new RectangleCollider2D())
                          .AddComponent(new RabbitBehavior())
                          .AddComponent(new SpriteAtlas(WaveContent.Assets.Textures.game_spritesheet, WaveContent.Assets.Textures.game_spritesheet_TextureName.rabbit))
                          .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Alpha));

            // Cached
            this.rabbitBehavior = this.entity.FindComponent <RabbitBehavior>();
            this.collider       = this.entity.FindComponent <RectangleCollider2D>();

            var materialModel = assetsContainer.LoadModel <MaterialModel>(WaveContent.Assets.Materials.StarParticleMaterial);

            // Particles
            this.entity.AddChild(new Entity("rabbitParticles")
                                 .AddComponent(new Transform2D())
                                 .AddComponent(ParticleFactory.CreateStarsParticle())
                                 .AddComponent(new MaterialsMap(materialModel.Material))
                                 .AddComponent(new ParticleSystemRenderer2D("rabbitParticles")));
        }
Ejemplo n.º 8
0
        protected override void LoadContent()
        {
            _taps = new List <Vector2>();
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            GameData    = new GamePersistance <GameData>(this);
            Pixel       = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Pixel.SetData(new[] { Color.White });
            Textures.LoadContent(Content);
            Fonts.LoadContent(Content);

            ParticleSystem = new ParticleEngine();
            ParticleColor  = Color.Black;
            MouseInput     = new MouseInput();
            TouchInput     = new TouchInput();
            UnifiedInput   = new UnifiedInput(this);
            KeyboardInput  = new KeyboardInput(this);


            UnifiedInput.MoveListeners.Add((v) =>
            {
                ParticleSystem.Add(new Emitter(v, new TimeSpan(0, 0, 0, 1),
                                               e => ParticleFactory.GenerateParticle(e, Textures.ParticleStar,
                                                                                     ParticleColor), 5, 20));
            });
            UnifiedInput.TapListeners.Add(OnTap);
            UnifiedInput.DraggedListeners.Add(OnDragged);

            //Branding.BackgroundColor = Color.Red;

            IsMouseVisible = false;
            BackGroundTune = Game.Audio.Play(Cues.Background, AudioChannels.Music, true);
        }
Ejemplo n.º 9
0
    /*
     * CollideWithAsteroid
     *
     * User has collided with asteroid. Show explosion, remove ship from
     * view, lock camera, and play game losing sound.
     */
    public void CollideWithAsteroid()
    {
        // Create explosion particles.
        ParticleFactory.Get(ParticleType.Collision).Run(spaceship);

        // Lock camera.
        GameObject.FindGameObjectWithTag("MainCamera")
        .GetComponent <CameraIntegration>()
        .Lock();

        // Lock astoid creation states. Do NOT let them disappear from
        // user view.
        GameObject.FindGameObjectWithTag("Player")
        .GetComponent <LevelGeneration>()
        .StopCoroutines();

        // Play game over sounds.
        var s = BeatBox.Instance;

        s.PlayGameLost();
        s.PlayCollision();

        // Hide spacehip by disabling all children renders.
        Renderer[] childs = this.gameObject
                            .GetComponentsInChildren <Renderer>();
        foreach (Renderer item in childs)
        {
            item.enabled = false;
        }
    }
Ejemplo n.º 10
0
        public void GameLoop(object sender, EventArgs args)
        {
            if (currentLevel.WavesAmount == 0)
            {
                currentLevel.IsCompleted = true;
                currentLevel.Particles.Add(ParticleFactory.CreateExit(currentLevel.Exit.Center));
            }
            if (player.IsDead)
            {
                ResetState();
            }
            if (currentLevel.IsCompleted && CollisionDetector.GetCollisionInfo(player.CollisionShape, currentLevel.Exit) != null)
            {
                currentLevel = LevelManager.MoveNextLevel();
                InitState();
            }

            var shouldRenderRaytracing = keyState.pressesOnPAmount % 2 == 1;
            var shouldRenderDebug      = keyState.pressesOnIAmount % 2 == 1;

            UpdateState(shouldRenderRaytracing);
            RenderPipeline.Render(currentLevel, camera, cursor.Position, shouldRenderRaytracing, shouldRenderDebug);

            AudioEngine.Update();
        }
    public void Execute(Transform position)
    {
        Debug.Log("Gatling fired!");

        AmmoFactory.CreateGatlingShot(position, Data);
        ParticleFactory.CreateShotSmoke(position);
    }
Ejemplo n.º 12
0
        private void CalculateEntityRespond(LivingEntity entity, Bullet bullet, List <AbstractParticleUnit> levelParticles)
        {
            var penetrationTimes =
                DynamicCollisionDetector.AreCollideWithDynamic(bullet, entity.CollisionShape, entity.Velocity);

            if (penetrationTimes == null)
            {
                return;
            }
            var penetrationPlace = bullet.Position + bullet.Velocity * penetrationTimes[0];

            entity.TakeHit(bullet.Damage);
            if (entity.Armor > 50)
            {
                bullet.IsStuck = true;
                levelParticles.Add(ParticleFactory.CreateSmallBloodSplash(penetrationPlace));
            }
            else
            {
                bullet.SlowDown();
                levelParticles.Add(ParticleFactory.CreateBloodSplash(penetrationPlace));
                levelParticles.Add(ParticleFactory.CreateBloodSplash(penetrationPlace));
            }

            if (entity.IsDead)
            {
                if (!entity.Velocity.Equals(Vector.ZeroVector))
                {
                    entity.MoveTo(entity.CollisionShape.Center + entity.Velocity * penetrationTimes[0]);
                }
                HandleKill(entity, entity.Position - bullet.Position, levelParticles);
            }
        }
Ejemplo n.º 13
0
        public InstantExplosionWeapon(string defaultPath, Camera camera)
        {
            if (sound == null)
                sound = new Sound(defaultPath + "Audio/laserfire3.wav");

            this.reloadTime = 1000;
            this.damage = 10;

            Texture t = new BasicTexture(defaultPath + "Texture/Particle/p.png");
            this.position = new Vector3f();
            this.direction = new Vector3f();
            pe = new PointEmitter(position);

            Vector3f maxV = new Vector3f(10.0f, 10.0f, 10.0f);
            Vector3f minV = maxV * -1.0f;
            Vector3f g = new Vector3f(0.0f, -0.001f, 0.0f);

            Color4f minC = new Color4f(1.0f, 0.7f, 0.7f, 0.0f);
            Color4f maxC = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);

            pf = new BillboardedParticleFactory(t, minV, maxV, g, 0.0f, 1.0f, minC, maxC, 0.2f);
            ps = new ParticleSystem(pe, pf, camera, false, 0.1f, 1000);
            pe.setActive(false);
            ps.reset();
        }
Ejemplo n.º 14
0
        private void UpdatePlayer()
        {
            var previousPosition = player.Position.Copy();

            player.UpdatePosition(keyState, currentLevel.StaticShapes);
            currentLevel.CollisionsInfo = CollisionSolver.ResolveCollisions(currentLevel.SceneShapes);
            AudioEngine.UpdateListenerPosition(player.Position);
            var realVelocity = player.Position - previousPosition;

            player.MeleeWeapon.MoveRangeBy(realVelocity);
            cursor.MoveBy(viewForm.GetCursorDiff() + realVelocity);
            player.UpdateSprites(cursor.Position);

            if (mouseState.RMB && player.MeleeWeapon.IsReady)
            {
                player.RaiseMeleeWeapon();
            }
            else if (mouseState.LMB && player.CurrentWeapon.IsReady && !player.IsMeleeWeaponInAction)
            {
                player.HideMeleeWeapon();
                var firedBullets = player.CurrentWeapon.Fire(player.Position, cursor);
                AudioEngine.PlayNewInstance("event:/gunfire/2D/misc/DROPPED_SHELL");
                currentLevel.Bullets.AddRange(firedBullets);
                currentLevel.Particles.Add(ParticleFactory.CreateShell(player.Position, cursor.Position - player.Position, player.CurrentWeapon));
            }

            player.IncrementTick();
        }
Ejemplo n.º 15
0
        protected override void CreateScene()
        {
            var camera2D = new FixedCamera2D("Camera2D")
            {
                BackgroundColor = this.backgroundColor
            };

            EntityManager.Add(camera2D);

            // Water particles
            Entity waterParticles = new Entity("waterParticles")
                                    .AddComponent(new Transform2D()
            {
                X = WaveServices.ViewportManager.VirtualWidth / 2,
                Y = WaveServices.ViewportManager.VirtualHeight / 2,
            })
                                    .AddComponent(ParticleFactory.CreateWaterParticles())
                                    .AddComponent(new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle.wpk", DefaultLayers.Additive)))
                                    .AddComponent(new ParticleSystemRenderer2D("waterParticles"));

            EntityManager.Add(waterParticles);

            Entity waterParticles2 = new Entity("waterParticles2")
                                     .AddComponent(new Transform2D()
            {
                X = WaveServices.ViewportManager.VirtualWidth / 2,
                Y = WaveServices.ViewportManager.VirtualHeight / 2,
            })
                                     .AddComponent(ParticleFactory.CreateWaterParticles())
                                     .AddComponent(new Material2D(new BasicMaterial2D(Directories.TexturePath + "waterParticle2.wpk", DefaultLayers.Additive)))
                                     .AddComponent(new ParticleSystemRenderer2D("waterParticles2"));

            EntityManager.Add(waterParticles2);
        }
Ejemplo n.º 16
0
    public void Execute(Transform position)
    {
        Debug.Log("Cannonball fired!");

        AmmoFactory.CreateCannonballShot(position, Data);
        ParticleFactory.CreateShotSmoke(position);
    }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rabbit" /> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="drawOrder">The draw order.</param>
        public Rabbit(Vector2 position, float drawOrder)
        {
            this.entity = new Entity()
                          .AddComponent(new Transform2D()
            {
                Origin    = Vector2.One / 2,
                X         = position.X,
                Y         = position.Y,
                DrawOrder = drawOrder,
                XScale    = 0.8f,
                YScale    = 0.8f,
            })
                          .AddComponent(new RectangleCollider())
                          .AddComponent(new RabbitBehavior())
                          .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "rabbit"))
                          .AddComponent(new SpriteAtlasRenderer(DefaultLayers.GUI));

            // Cached
            this.rabbitBehavior = this.entity.FindComponent <RabbitBehavior>();
            this.collider       = this.entity.FindComponent <RectangleCollider>();

            // Particles
            this.entity.AddChild(new Entity("rabbitParticles")
                                 .AddComponent(new Transform2D())
                                 .AddComponent(ParticleFactory.CreateStarsParticle())
                                 .AddComponent(new Material2D(new BasicMaterial2D(Directories.TexturePath + "starParticle.wpk", DefaultLayers.Additive)))
                                 .AddComponent(new ParticleSystemRenderer2D("rabbitParticles")));
        }
Ejemplo n.º 18
0
        public InstantExplosionWeapon(string defaultPath, Camera camera)
        {
            if (sound == null)
            {
                sound = new Sound(defaultPath + "Audio/laserfire3.wav");
            }

            this.reloadTime = 1000;
            this.damage     = 10;

            Texture t = new BasicTexture(defaultPath + "Texture/Particle/p.png");

            this.position  = new Vector3f();
            this.direction = new Vector3f();
            pe             = new PointEmitter(position);

            Vector3f maxV = new Vector3f(10.0f, 10.0f, 10.0f);
            Vector3f minV = maxV * -1.0f;
            Vector3f g    = new Vector3f(0.0f, -0.001f, 0.0f);

            Color4f minC = new Color4f(1.0f, 0.7f, 0.7f, 0.0f);
            Color4f maxC = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);

            pf = new BillboardedParticleFactory(t, minV, maxV, g, 0.0f, 1.0f, minC, maxC, 0.2f);
            ps = new ParticleSystem(pe, pf, camera, false, 0.1f, 1000);
            pe.setActive(false);
            ps.reset();
        }
Ejemplo n.º 19
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.5f - random.NextDouble(), 0.5f - random.NextDouble());
            tmp.stretch(new Vector3f((float)random.NextDouble() * side.x, (float)random.NextDouble() * side.y, (float)random.NextDouble() * side.z));
            tmp.add(position);

            return particleFactory.createParticle(tmp, false, null);
        }
Ejemplo n.º 20
0
    private void Start()
    {
        var pathFinder = FindObjectOfType <Pathfinder>();
        var path       = pathFinder.GetPath();

        StartCoroutine(FollowPath(path));
        _particleFactory = FindObjectOfType <ParticleFactory>();
    }
Ejemplo n.º 21
0
 public SponzaScene(GraphicsDevice device, SkyboxSceneService skybox, GeometryFactory geometry, ParticipatingMediaFactory participatingMedia, ParticleFactory particles)
 {
     this.Device             = device;
     this.Skybox             = skybox;
     this.Geometry           = geometry;
     this.ParticipatingMedia = participatingMedia;
     this.Particles          = particles;
 }
Ejemplo n.º 22
0
        public void EnsureDirectionLoadCalled()
        {
            var l = new Log();
            var t = ParticleType.Direction;
            var p = ParticleFactory.Get(t, l);

            Assert.AreEqual(l.Get("BaseParticle#Load"), 1);
        }
Ejemplo n.º 23
0
 private void InitializeSystems()
 {
     RenderMachine.Initialize(viewForm, screenSize);
     AudioEngine.Initialize();
     LevelManager.Initialize();
     ParticleFactory.Initialize();
     AbstractWeaponFactory.Initialize();
     BotBank.Initialize();
 }
Ejemplo n.º 24
0
        public void ParticleFactoryCreateTestNotExisting()
        {
            EntityCreateArgs args = new EntityCreateArgs("random");

            SceneManager.Instance.LoadScene <MockScene>();
            ParticleFactory factory = new ParticleFactory();

            Assert.IsNull(factory.Create(args), "Sukurtas objektas kai turėjo gražinti null");
        }
Ejemplo n.º 25
0
        public void EnsureDirectionCurrentGameObjectsCalled()
        {
            var l = new Log();
            var t = ParticleType.Direction;
            var p = ParticleFactory.Get(t, l);

            p.CurrentGameObjects();
            Assert.AreEqual(l.Get("BaseParticle#CurrentGameObjects"), 1);
        }
Ejemplo n.º 26
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.5f - random.NextDouble(), 0.5f - random.NextDouble());

            tmp.stretch(new Vector3f((float)random.NextDouble() * side.x, (float)random.NextDouble() * side.y, (float)random.NextDouble() * side.z));
            tmp.add(position);

            return(particleFactory.createParticle(tmp, false, null));
        }
Ejemplo n.º 27
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.5f - random.NextDouble(), 0.5f - random.NextDouble());
            tmp.Normalize();
            tmp.stretch(radius);
            tmp.add(position);

            return particleFactory.createParticle(tmp, false, null);
        }
Ejemplo n.º 28
0
    public static ParticleFactory GetInstance()
    {
        if (m_Instance == null)
        {
            m_Instance = new ParticleFactory();
        }

        return(m_Instance);
    }
Ejemplo n.º 29
0
 private void Fire(Vector aim, List <Bullet> sceneBullets, List <AbstractParticleUnit> particles)
 {
     RotateToPrey(aim);
     if (currentWeapon.IsReady)
     {
         sceneBullets.AddRange(currentWeapon.Fire(Position, sight));
         particles.Add(ParticleFactory.CreateShell(Position, sight, currentWeapon));
     }
 }
Ejemplo n.º 30
0
        public override Particle emit(ParticleFactory particleFactory)
        {
            Vector3f tmp = new Vector3f(0.5f - random.NextDouble(), 0.0f, 0.5f - random.NextDouble());

            tmp.Normalize();
            tmp.stretch((float)random.NextDouble() * radius);
            tmp.add(position);

            return(particleFactory.createParticle(tmp, false, null));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Override by the derived classes to describe how new particles are emitted
        /// </summary>
        /// <param name="particleCount">Particle count.</param>
        /// <param name="receiver">Receiver.</param>
        protected virtual void emitParticles(int particleCount, ParticleFactory factory, ReceiverHandler receiver)
        {
            SSParticle newParticle = factory();

            for (int i = 0; i < particleCount; ++i)
            {
                configureNewParticle(newParticle);
                receiver(newParticle);
            }
        }
Ejemplo n.º 32
0
    /*
     * Start
     *
     * Grab ship rigidbody, create the desired particle type (specified
     * in Unity editor) and begin displaying particles to ship.
     */
    void Start()
    {
        // Grab spaceship from attached game object.
        spaceship = GetComponent <Rigidbody>();

        // Create ship thruster particles.
        thrusters = ParticleFactory.Get(ParticleType.Direction);
        //adding to the ship score and health (cosette)
        myHealth = GetComponent <UpdateHealth>();
        myScore  = GetComponent <UpdateScore>();
    }
Ejemplo n.º 33
0
        public void ParticleFactoryCreateTest()
        {
            EntityCreateArgs args = new EntityCreateArgs("explosion");

            SceneManager.Instance.LoadScene <MockScene>();
            ParticleFactory factory = new ParticleFactory();
            Entity          element = factory.Create(args);
            bool            deleted = SceneManager.Instance.CurrentScene.DestroyEntity(element);

            Assert.IsTrue(deleted, "Scenoje nerastas objektas");
        }
Ejemplo n.º 34
0
 protected override void emitParticles(int particleCount, ParticleFactory factory, ReceiverHandler particleReceiver)
 {
     SSParticle newParticle = factory();
     BodiesFieldGenerator.NewBodyDelegate bodyReceiver = (id, scale, pos, orient) => {
         configureNewParticle(newParticle);
         newParticle.pos = pos;
         newParticle.masterScale *= scale;
         newParticle.orientation += OpenTKHelper.QuaternionToEuler(ref orient);
         particleReceiver(newParticle);
         return true;
     };
     _bodiesGenerator.Generate(particleCount, bodyReceiver);
 }
Ejemplo n.º 35
0
        public ParticleSystem(ParticleEmitter particleEmitter, ParticleFactory particleFactory, Camera activeCamera, bool endlessLife, float emitterLife, int maxParticles)
        {
            this.particleEmitter = particleEmitter;
            this.particleFactory = particleFactory;

            this.endlessLife = endlessLife;
            this.emitterLife = defaultEmitterLife = emitterLife;
            this.maxParticles = maxParticles;
            listParticles = new List<Particle>(maxParticles);
            listCollisionSurfaces = new List<CollisionSurface>();
            listManipulators = new List<Manipulator>();
            this.activeCamera = activeCamera;

            boundingSphere = new Sphere(particleEmitter.getPosition(), particleFactory.getRange());
        }
Ejemplo n.º 36
0
 public abstract Particle emit(ParticleFactory particleFactory);
Ejemplo n.º 37
0
 public override Particle emit(ParticleFactory particleFactory)
 {
     return particleFactory.createParticle(position, false, null);
 }
 public override void SetDefaultValues()
 {
     explodesWith = new List<string>();
     ParticleFactory = null;
     MaxParticles = 0;
 }
Ejemplo n.º 39
0
 protected override void emitParticles(int particleCount, ParticleFactory factory, ReceiverHandler particleReceiver)
 {
     SSParticle newParticle = factory();
     ParticlesFieldGenerator.NewParticleDelegate fieldReceiver = (id, pos) => {
         configureNewParticle(newParticle);
         newParticle.pos = pos;
         particleReceiver(newParticle);
         return true;
     };
     m_fieldGenerator.Generate(particleCount, fieldReceiver);
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Override by the derived classes to describe how new particles are emitted
 /// </summary>
 /// <param name="particleCount">Particle count.</param>
 /// <param name="receiver">Receiver.</param>
 protected virtual void emitParticles(int particleCount, ParticleFactory factory, ReceiverHandler receiver)
 {
     SSParticle newParticle = factory();
     for (int i = 0; i < particleCount; ++i) {
         configureNewParticle (newParticle);
         receiver (newParticle);
     }
 }
Ejemplo n.º 41
0
 public void emitParticles(ParticleFactory factory, ReceiverHandler receiver)
 {
     int numToEmit = _rand.Next(particlesPerEmissionMin, particlesPerEmissionMax);
     emitParticles(numToEmit, factory, receiver);
 }
Ejemplo n.º 42
0
        public void simulateEmissions(float deltaT, ParticleFactory factory, ReceiverHandler receiver)
        {
            if (totalEmissionsLeft == 0) return;

            if (_initialDelay > 0f) {
                // if initial delay is needed
                _initialDelay -= deltaT;
                if (_initialDelay > 0f) {
                    return;
                }
            }

            _timeSinceLastEmission += deltaT;
            float diff;
            while ((diff = _timeSinceLastEmission - _nextEmission) > 0f) {
                emitParticles(factory, receiver);
                if (totalEmissionsLeft > 0 && --totalEmissionsLeft == 0) {
                    reset ();
                    break;
                } else {
                    _timeSinceLastEmission = diff;
                    _nextEmission = Interpolate.Lerp(emissionIntervalMin, emissionIntervalMax,
                        (float)_rand.NextDouble());
                }
            }
        }