示例#1
0
        public void Update(GameTime gameTime)
        {
            if (this.Circle != null)
            {
                this.Circle.Dispose();
            }

            this.Circle = DrawUtils.CreateCircle(this.Size + this.MinSize, this._mainGame.GraphicsDevice);
            this.Size   = Shield;

            if (!this._mainGame.IsPaused)
            {
                if ((this.Shield < 100) && (this.Shield > 0))
                {
                    Int32 tempMulti = 15;
                    if (Int32.TryParse(this.Shield.ToString().ElementAt(0).ToString(), out tempMulti))
                    {
                        this.Multiplier = tempMulti;
                    }
                }
                else
                {
                    this.Multiplier = 15;
                }
            }
        }
        public void Update(GameTime gameTime)
        {
            if (!this._mainGame.IsActive)
            {
                this._mcParticleSystemOterColor.Game.ResetElapsedTime();
                this._mcParticleSystem.Game.ResetElapsedTime();
            }

            if (!this._mainGame.IsPaused)
            {
                MusicPlayer  mp = this._mainGame.GameManager.GetComponent <MusicPlayer>();
                InputHandler ih = this._mainGame.GameManager.GetComponent <InputHandler>();

                this._bannedOutsideCircleArea = (Int32)(Math.Exp(mp.AvarageFrequency * 8.4f));

                if (this.OutsideCircle != null)
                {
                    this.OutsideCircle.Dispose();
                }

                this.OutsideCircle = DrawUtils.CreateCircle(this._bannedOutsideCircleArea, this._mainGame.GraphicsDevice);

                DynamicWorldCounter dwc = this._mainGame.GameManager.GetComponent <DynamicWorldCounter>();

                Matrix  rot  = Matrix.CreateRotationZ(dwc.ZRotationAngle);
                Vector3 vec3 = Vector3.Transform(Vector3.Up, rot);
                vec3.Normalize();

                Matrix sViewMatrix = Matrix.CreateLookAt(this._mainGame.MainCameraPosition, Vector3.Zero, vec3);

                // Setup the Camera's Projection matrix by specifying the field of view (1/4 pi), aspect ratio, and the near and far clipping planes
                //Matrix sProjectionMatrix = Matrix.CreateOrthographic(this._mainGame.GraphicsDevice.Viewport.Width, this._mainGame.GraphicsDevice.Viewport.Height, 1, 10000);//
                Matrix sProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)this._mainGame.GraphicsDevice.Viewport.Width / (float)this._mainGame.GraphicsDevice.Viewport.Height, 1, 10000);

                // Set the Particle System's World, View, and Projection matrices so that it knows how to draw the particles properly.
                this._mcParticleSystem.SetWorldViewProjectionMatrices(Matrix.Identity, sViewMatrix, sProjectionMatrix);

                // Update the Particle System for craft
                this._mcParticleSystem.SetCameraPosition(this._mainGame.MainCameraPosition);
                this._mcParticleSystem.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

                // Set the Particle System's World, View, and Projection matrices so that it knows how to draw the particles properly.
                this._mcParticleSystemOterColor.SetWorldViewProjectionMatrices(Matrix.Identity, sViewMatrix, sProjectionMatrix);


                // Update the Particle System
                this._mcParticleSystemOterColor.SetCameraPosition(this._mainGame.MainCameraPosition);
                this._mcParticleSystemOterColor.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

                if ((!new Rectangle((Int32)(this.EmitterRealPos1.X - this._bannedOutsideCircleArea), (Int32)(this.EmitterRealPos1.Y - this._bannedOutsideCircleArea),
                                    this.OutsideCircle.Width, this.OutsideCircle.Height).Contains(new Rectangle(ih.ActualMouseState.X, ih.ActualMouseState.Y, 1, 1))) &&
                    (!new Rectangle((Int32)(this.EmitterRealPos2OterColor.X - this._bannedOutsideCircleArea), (Int32)(this.EmitterRealPos2OterColor.Y - this._bannedOutsideCircleArea),
                                    this.OutsideCircle.Width, this.OutsideCircle.Height).Contains(new Rectangle(ih.ActualMouseState.X, ih.ActualMouseState.Y, 1, 1))))
                {
                    this._activeMousePosition = new Vector2(ih.ActualMouseState.X, ih.ActualMouseState.Y);
                }

                this._mouse3d = this._mainGame.MainViewport.Unproject(new Vector3(this._activeMousePosition.X, this._activeMousePosition.Y, 0), this._mcParticleSystem.Projection, this._mcParticleSystem.View, this._mcParticleSystem.World);
                this._mouse3d = new Vector3(this._mouse3d.X, this._mouse3d.Y, 0) * this._mouse3d.Z * (-1);//don't know why but it works!?

                this._mcParticleSystem.MouseMagnet(this._mouse3d);
                this._mcParticleSystemOterColor.MouseMagnet(this._mouse3d);

                //mouse movement to particle lux power
                if (gameTime.TotalGameTime - this._previouslyGameTime > this._mainGame.OneSecond)
                {
                    if ((this._oldActiveMousePosition.X != -10) && (this._activeMousePosition.X != -10))
                    {
                        this._mcParticleSystem.CollectingPower          = Vector2.Distance(this._activeMousePosition, this._oldActiveMousePosition) * 0.1f;
                        this._mcParticleSystemOterColor.CollectingPower = this._mcParticleSystem.CollectingPower;//Vector2.Distance(this._activeMousePosition, this._oldActiveMousePosition) * 0.1f;
                    }

                    if (this._mcParticleSystem.CollectingPower > 13)
                    {
                        this._mcParticleSystem.CollectingPower          = 13;
                        this._mcParticleSystemOterColor.CollectingPower = 13;
                        this.BonusPower++;
                        if (this.BonusPower >= 100)
                        {
                            this.BonusPower = 100;
                        }
                    }

                    this._oldActiveMousePosition = this._activeMousePosition;
                    this._previouslyGameTime     = gameTime.TotalGameTime;
                }

                if ((ih.ActualMouseState.LeftButton == ButtonState.Pressed) && (this.BonusPower >= 100))
                {
                    this._bonusLuxActive = true;
                }

                if ((ih.ActualMouseState.RightButton == ButtonState.Pressed) && (this.BonusFieldPrepar))
                {
                    this._mcParticleSystem.BonusShield(this._mouse3d);
                    this._mcParticleSystemOterColor.BonusShield(this._mouse3d);
                    this.BonusFieldActive = true;
                }

                if ((ih.ActualMouseState.RightButton == ButtonState.Released) && (this.BonusFieldActive))
                {
                    //bonusTime = 5;
                    //timeToBonus = 35;
                    this.BonusFieldPrepar = false;
                    this.BonusFieldActive = false;
                    if (this.BonusFieldDisabled != null)
                    {
                        this.BonusFieldDisabled.Invoke(null, EventArgs.Empty);
                    }
                }

                if (this._bonusLuxActive)
                {
                    this._mcParticleSystem.BonusLux(this._mouse3d);
                    this._mcParticleSystemOterColor.BonusLux(this._mouse3d);
                    this.BonusPower--;
                }

                if (this.BonusPower <= 0)
                {
                    this._bonusLuxActive = false;
                }

                //emitters position
                this._mcParticleSystem.Emitter.PositionData.Position = new Vector3((-1) * EMITTER_DISTANCE, EMITTER_DISTANCE, 0);
                this.EmitterRealPos1 = this._mainGame.MainViewport.Project(this._mcParticleSystem.Emitter.PositionData.Position, this._mcParticleSystem.Projection, this._mcParticleSystem.View, this._mcParticleSystem.World);

                this._mcParticleSystemOterColor.Emitter.PositionData.Position = new Vector3(EMITTER_DISTANCE, (-1) * EMITTER_DISTANCE, 0);
                this.EmitterRealPos2OterColor = this._mainGame.MainViewport.Project(this._mcParticleSystemOterColor.Emitter.PositionData.Position, this._mcParticleSystem.Projection, this._mcParticleSystem.View, this._mcParticleSystem.World);

                if (this._zRotationOfEmitter >= 360)
                {
                    this._zRotationOfEmitter = 0f;
                }

                this._zRotationOfEmitter += 0.1f;
                //emitters rotation
                this._mcParticleSystem.Emitter.OrientationData.Rotate(Matrix.CreateRotationZ(MathHelper.ToRadians(this._zRotationOfEmitter)));
                this._mcParticleSystemOterColor.Emitter.OrientationData.Rotate(Matrix.CreateRotationZ(MathHelper.ToRadians(-this._zRotationOfEmitter)));

                //particles per second
                this._mcParticleSystem.Emitter.ParticlesPerSecond          = mp.AvarageFrequency * 60;
                this._mcParticleSystem.SimulationSpeed                     = mp.AvarageFrequency * 2;
                this._mcParticleSystemOterColor.SimulationSpeed            = mp.AvarageFrequency * 2;
                this._mcParticleSystemOterColor.Emitter.ParticlesPerSecond = mp.AvarageFrequency * 60;


                //if sound avarage bigger than 0.5 it makes boom effect
                if (mp.AvarageFrequency > 0.5f)
                {
                    this._particleDeflection = this._particleDeflection * (-1);
                    this._mcParticleSystem.AddParticles((Int32)(8 * mp.AvarageFrequency));

                    this._mcParticleSystemOterColor.AddParticles((Int32)(8 * mp.AvarageFrequency));
                }

                //sound avarage to particle system
                this._mcParticleSystem.AvarageFrequency          = mp.AvarageFrequency;
                this._mcParticleSystemOterColor.AvarageFrequency = mp.AvarageFrequency;

                this.ParticleForEach(this._mcParticleSystem, mp.AvarageFrequency);
                this.ParticleForEach(this._mcParticleSystemOterColor, mp.AvarageFrequency);
            }
        }
示例#3
0
 public void LoadContent()
 {
     this.Circle = DrawUtils.CreateCircle(this.Size + this.MinSize, this._mainGame.GraphicsDevice);
 }