예제 #1
0
        public void LoadContent()
        {
            this._mcParticleSystem = new DefaultTexturedQuadParticleSystemTemplate(this._mainGame, new Vector3(1f, 1.7f, 0), new Vector3(1f, 1.7f, 1f), true, false);
            this._mcParticleSystem.AutoInitialize(this._mainGame.GraphicsDevice, this._mainGame.Content, null);

            this._mcParticleSystemOterColor = new DefaultTexturedQuadParticleSystemTemplate(this._mainGame, new Vector3(0, 0, 1.7f), new Vector3(1, 1, 1.7f), false, true);
            this._mcParticleSystemOterColor.AutoInitialize(this._mainGame.GraphicsDevice, this._mainGame.Content, null);
        }
예제 #2
0
        private void ParticleForEach(DefaultTexturedQuadParticleSystemTemplate localParticleSystem, float avarage)
        {
            Player player = this._mainGame.GameManager.GetComponent <Player>();

            if (player != null && localParticleSystem != null && localParticleSystem.ActiveParticles != null && localParticleSystem.ActiveParticles.Count > 0)
            {
                foreach (DefaultQuadParticle particle in localParticleSystem.ActiveParticles)
                {
                    particle.Size = avarage * 15f;

                    Vector3 paticlePosition = this._mainGame.MainViewport.Project(particle.Position, localParticleSystem.Projection, localParticleSystem.View, localParticleSystem.World);

                    //shield
                    if ((new Rectangle((int)(this._mainGame.MainViewport.Width / 2 - player.Shield), (int)(this._mainGame.MainViewport.Height / 2 - player.Shield), player.GetCircleWidth(), player.GetCircleHeight()).Contains(new Rectangle((int)(paticlePosition.X - 12), (int)(paticlePosition.Y - 12), (int)(12), (int)(12)))) ||
                        (new Rectangle((int)(this._mainGame.MainViewport.Width / 2 - player.Shield), (int)(this._mainGame.MainViewport.Height / 2 - player.Shield), player.GetCircleWidth(), player.GetCircleHeight()).Contains(new Rectangle((int)(paticlePosition.X + 12), (int)(paticlePosition.Y + 12), (int)(12), (int)(12)))))
                    {
                        particle.Lifetime = PARTICLE_DEAD_TIME;

                        if (this.ParticleHitPlayer != null)
                        {
                            this.ParticleHitPlayer.Invoke(player, EventArgs.Empty);
                        }
                    }

                    if ((paticlePosition.X > this._mainGame.MainViewport.Width + PARTICLE_OUTSIDE_AREA) || (paticlePosition.X < (-1) * PARTICLE_OUTSIDE_AREA))
                    {
                        particle.Lifetime = PARTICLE_DEAD_TIME;
                        //particlesPerGame++;
                        if (this.ParticleOutOfScreen != null)
                        {
                            this.ParticleOutOfScreen.Invoke(null, EventArgs.Empty);
                        }
                    }

                    if ((paticlePosition.Y > this._mainGame.MainViewport.Height + PARTICLE_OUTSIDE_AREA) || (paticlePosition.Y < (-1) * PARTICLE_OUTSIDE_AREA))
                    {
                        particle.Lifetime = PARTICLE_DEAD_TIME;
                        //particlesPerGame++;
                        if (this.ParticleOutOfScreen != null)
                        {
                            this.ParticleOutOfScreen.Invoke(null, EventArgs.Empty);
                        }
                    }

                    //projection paticle on canvas
                    if (particle.Visible)
                    {
                        if ((this._activeMousePosition.X >= paticlePosition.X - particle.Width * PARTICLE_SPACE) && (this._activeMousePosition.X <= paticlePosition.X + particle.Width * PARTICLE_SPACE))
                        {
                            if ((this._activeMousePosition.Y <= paticlePosition.Y + particle.Height * PARTICLE_SPACE) && (this._activeMousePosition.Y >= paticlePosition.Y - particle.Height * PARTICLE_SPACE))
                            {
                                particle.Visible  = false;
                                particle.Lifetime = PARTICLE_DEAD_TIME;

                                if (this.ParticleHitMouse != null)
                                {
                                    this.ParticleHitMouse.Invoke(player, EventArgs.Empty);
                                }
                            }
                        }
                    }
                }
            }
        }