Esempio n. 1
0
        public Game1()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - 50;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - 50;
            graphics.PreferMultiSampling = true;
            screenBounds = new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            graphics.IsFullScreen = true;

            this.IsMouseVisible = true;

            particleEffects.Add("Heart", null);
            particleEffects.Add("Sword", null);
            particleEffects.Add("Death", null);

            particleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };

            Parameters = Serialiser.DeserialiseFromFile<Params>("./params.xml");
            Parameters.Growth = Parameters.Growth / 100;
            Parameters.Mutation = Parameters.Mutation / 100;
            Parameters.Reproduction = Parameters.Reproduction / 100;
        }
Esempio n. 2
0
 public ParticleManager()
 {
     particleEffects = new Dictionary<string, ParticleEffect>();
     particleRenderer = new SpriteBatchRenderer
     {
         GraphicsDeviceService = Game1.graphics
     };
 }
 public LightCausingParticleObject(ParticleEffect effect, Renderer partilceRenderer, PointLight pointLight, ICollidableTile trackingObject)
 {
     Enabled = true;
     Effect = effect;
     Light = pointLight;
     TrackingObject = trackingObject;
     m_particleRenderer = partilceRenderer;
 }
Esempio n. 4
0
        /// <summary>
        /// 
        /// </summary>
        public PartyManager_cl()
        {
            mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = FNA.Game_cl.BaseInstance.Graphics
            };

            mParticleRenderer.LoadContent(FNA.Game_cl.BaseInstance.Content);
        }
        public Scene(Game1 game)
        {
            this.m_game = game;

            DirectionalLights = new List<TestBed.Lighting.DirectionalLight>();
            PointLights = new List<PointLight>();
            ParticleEffects = new List<LightCausingParticleObject>();

            m_particleRenderer = new SpriteBatchRenderer()
            {
                GraphicsDeviceService = m_game.graphics
            };
        }
Esempio n. 6
0
        public Box(Game game, Vector2 position)
            : base(game)
        {
            mContentManager = new ContentManager(game.Services);
            mWorld = (World)game.Services.GetService(typeof(World));
            mGraphics = (GraphicsDeviceManager)game.Services.GetService(typeof(GraphicsDeviceManager));
            mSpriteBatch = (SpriteBatch)game.Services.GetService(typeof(SpriteBatch));

            particleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = mGraphics
            };
            particleEffect = new ParticleEffect();
        }
Esempio n. 7
0
        private float mSpeedTimerInSeconds = 3.5f; // Increase ball speed every 3.5 seconds

        #endregion Fields

        #region Constructors

        public Ball(Texture2D texture,
            Vector2 position,
            World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics)
            : base(world, debugViewXNA, content, graphics)
        {
            this.mTexture = texture;
            this.mWidth = ConvertUnits.ToSimUnits(this.mTexture.Width);
            this.mHeight = ConvertUnits.ToSimUnits(this.mTexture.Height);
            this.mOrigin = new Vector2(this.mWidth / 2f, this.mHeight / 2f);

            this.mSpriteEffects = SpriteEffects.None;

            this.mPosition = ConvertUnits.ToSimUnits(position);

            this.mBody = BodyFactory.CreateCircle(this.mWorld,
               this.Radius,
               0.5f,
               this.mPosition);

            this.mBody.BodyType = BodyType.Dynamic;
            this.mBody.Restitution = 1f;
            this.mBody.Friction = 0;
            this.mBody.Inertia = float.MaxValue;

            this.mBody.OnCollision += new OnCollisionEventHandler(OnCollision);
            this.mBody.OnSeparation += new OnSeparationEventHandler(OnSeparation);
            this.mWorld.ContactManager.OnBroadphaseCollision += OnBroadphaseCollision;
            this.mBody.FixtureList[0].AfterCollision += new AfterCollisionEventHandler(OnAfterCollision);

            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleEffect = new ParticleEffect();

            this.mParticleRenderer.LoadContent(this.mContent);
            this.mParticleEffect = this.mContent.Load<ParticleEffect>(@"Effects\basicSparks");
            this.mParticleEffect.LoadContent(this.mContent);
            this.mParticleEffect.Initialise();

            this.LoadContent();
        }
Esempio n. 8
0
        public Paddle(Texture2D texture,
            Vector2 position,
            World world,
            DebugViewXNA debugViewXNA,
            ContentManager content,
            GraphicsDeviceManager graphics)
            : base(world, debugViewXNA, content, graphics)
        {
            this.mTexture = texture;
            this.mWidth = ConvertUnits.ToSimUnits(this.mTexture.Width);
            this.mHeight = ConvertUnits.ToSimUnits(this.mTexture.Height);
            this.mOrigin = new Vector2(this.mWidth / 2f, this.mHeight / 2f);

            this.mSpriteEffects = SpriteEffects.None;

            this.mPosition = ConvertUnits.ToSimUnits(position);

            this.mBody = BodyFactory.CreateRectangle(this.mWorld,
                this.mWidth,
                this.mHeight,
                1f,
                this.mPosition);

            this.mBody.BodyType = BodyType.Dynamic;

            this.mJointWorldAnchor = this.mPosition;

            this.mFixedPrismJoint = new FixedPrismaticJoint(this.mBody,
                 this.mJointWorldAnchor,
                 this.mJointAxis);

            this.mFixedPrismJoint.LimitEnabled = true;
            this.mFixedPrismJoint.LowerLimit = this.mJointLowerLimit;
            this.mFixedPrismJoint.UpperLimit = this.mJointUpperLimit;
            this.mFixedPrismJoint.Enabled = true;
            this.mWorld.AddJoint(this.mFixedPrismJoint);

            this.mBody.OnCollision += new OnCollisionEventHandler(OnCollision);
            this.mBody.OnSeparation += new OnSeparationEventHandler(OnSeparation);
            this.mBody.FixtureList[0].AfterCollision += new AfterCollisionEventHandler(OnAfterCollision);

            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleEffect = new ParticleEffect();

            this.mParticleRenderer.LoadContent(this.mContent);
            this.mParticleEffect = this.mContent.Load<ParticleEffect>(@"Effects\basicSparks");
            this.mParticleEffect.LoadContent(this.mContent);
            this.mParticleEffect.Initialise();
        }
 public MercuryLineParticleEffect(Renderer renderer, Emitter emitter)
 {
     _renderer = renderer;
     _emitter = (LineEmitter)emitter;
 }
        /// <summary>
        /// Draws the specified effect.
        /// </summary>
        /// <param name="effect">The effect.</param>
        /// <param name="renderer">The renderer.</param>
        public void Draw(ParticleEffect effect, Renderer renderer)
        {
            this.uxActiveParticlesLabel.Text = String.Format("{0} Active Particles", effect.ActiveParticlesCount);

            this.uxEffectPreview.ParticleEffect = effect;
            this.uxEffectPreview.Renderer = renderer;

            this.uxEffectPreview.Invalidate();
        }
Esempio n. 11
0
        public MainGame()
        {
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = gameWidth;
            graphics.PreferredBackBufferHeight = gameHeight;

            //graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            //graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            this.graphics.IsFullScreen = isFullScreen;

            Content.RootDirectory = "Content";

               /* particleEffect = new ParticleEffect
            {

                new Emitter
                {
                    Budget = 1000,
                    Term = 3f,

                    Name = "FirstEmitter",
                    BlendMode = EmitterBlendMode.Alpha,
                    ReleaseQuantity = 100,
                    ReleaseRotation = new VariableFloat {Value = 0f, Variation = MathHelper.Pi},
                    ReleaseScale = 64f,
                    ReleaseSpeed = new VariableFloat { Value = 64f , Variation = 32f },
                    ParticleTextureAssetName = "particle1",

                    Modifiers = new ModifierCollection
                    {
                        new OpacityModifier
                        {

                            Initial= 1f,
                            Ultimate  = 0f,
                        },

                         new ColourModifier
                         {
                             InitialColour = Color.Tomato.ToVector3(),
                             UltimateColour = Color.LimeGreen.ToVector3(),
                         },

                    },

                },
            }; */

            particleEffect = new ParticleEffect();
            particleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };
        }
Esempio n. 12
0
        private void SwitchRenderer(string type)
        {
            switch (type)
            {
                case "PointSpriteRenderer":
                    {
                        this.Renderer = new PointSpriteRenderer
                        {
                            BlendMode = SpriteBlendMode.Additive,
                            GraphicsDeviceService = this.GraphicsDeviceManager
                        };

                        this.Renderer.LoadContent(base.Content);

                        break;
                    }
                case "SpriteBatchRenderer":
                    {
                        this.Renderer = new SpriteBatchRenderer
                        {
                            BlendMode = SpriteBlendMode.Additive,
                            GraphicsDeviceService = this.GraphicsDeviceManager
                        };

                        this.Renderer.LoadContent(base.Content);

                        break;
                    }
            }

            this.ControlPanel.RendererPropertyGridWrapper = this.Renderer;
        }
Esempio n. 13
0
        public GOEffect(GraphicsDeviceManager _graphics, ContentManager _Content)
        {
            graphics = _graphics;
            Content = _Content;

            effect = new ParticleEffect();
            renderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics};

            Visible = true;
        }
Esempio n. 14
0
File: Snake.cs Progetto: eogas/snake
        public Snake()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            dlgHiScore = new ModalHiScoreDialog();
            xmler = new XmlSerializer(typeof(HighScoreList));

            if (File.Exists(System.Environment.CurrentDirectory + "\\HighScores.xml"))
            {
                XmlReader reader = XmlReader.Create(System.Environment.CurrentDirectory + "\\HighScores.xml");
                highScores = xmler.Deserialize(reader) as HighScoreList;
                reader.Close();
                highScores.Scores.Sort();
                highScores.Scores.Reverse();
            }
            else
                highScores = new HighScoreList();

            renderer = new SpriteBatchRenderer()
            {
                GraphicsDeviceService = graphics
            };
            explode = new ParticleEffect();

            crunch = Content.Load<SoundEffect>("crunch");
            boom = Content.Load<SoundEffect>("boom");
            hurt = Content.Load<SoundEffect>("hurt");
        }
 public MercuryPointParticleEffect(Renderer renderer, Emitter trailEmitter, Emitter explosionEmitter)
 {
     this.Renderer = renderer;
     this.TrailEmitter = trailEmitter;
     this.ExplosionEmitter = explosionEmitter;
 }
Esempio n. 16
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Create new renderer and set its graphics devide to "this" device
            myRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };
            myEffect = new ParticleEffect();
        }
 public ParticleEffectManager(GraphicsDeviceManager graphics, ref Matrix transform) {
     particleRenderer = new SpriteBatchRenderer();
     particleRenderer.GraphicsDeviceService = graphics;
     this.transform = transform;
 }
 /// <summary>
 /// Constructor which specifies a renderer.
 /// </summary>
 /// <param name="game">A reference to the game object.</param>
 /// <param name="renderer">The renderer used to render the effect.</param>
 public ParticleEffect(Game game, Renderer renderer) : base(game)
 {
     game.Components.Add(this);
     this._renderer = renderer;
 }
Esempio n. 19
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void Activate(bool instancePreserved)
        {
            if (!instancePreserved)
            {
                if (content == null)
                    content = new ContentManager(ScreenManager.Game.Services, "Content");

                #region Instantiating Fields:

                gameFont = ScreenManager.Font;

                world = new GameWorld(9.8f * Vector2.UnitY, 0.4f, new Camera2D(ScreenManager.GraphicsDevice));

                player = new Player(this, world, camera);
                player.Initialize();
                player.Position = new Vector2(0, 50);

                scenario = new Scenario(this, world, camera);
                scenario.Initialize();

                camera.Zoom = 7f;
                camera.trakingSpeedMult = new Vector2(0.5f, 0.25f);
                camera.trakingOffset = new Vector2(0f, -2f);
                camera.TrackingBody = player.getBody(0);
                camera.Update(new GameTime());
                camera.Jump2Target();

                debugView = new DebugViewXNA(world);
                debugView.AppendFlags(DebugViewFlags.DebugPanel | DebugViewFlags.PerformanceGraph);
                debugView.AppendFlags(DebugViewFlags.ContactNormals | DebugViewFlags.ContactPoints);
                debugView.DefaultShapeColor = Color.Black;
                debugView.SleepingShapeColor = Color.LightGray;

                collectibles = new List<Collectible>();
                myEffect = new ParticleEffect();
                myRenderer = new SpriteBatchRenderer
                {
                    GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService))
                };
                sbRenderer = new SpriteBatchRenderer
                {
                    GraphicsDeviceService = (IGraphicsDeviceService)ScreenManager.Game.Services.GetService(typeof(IGraphicsDeviceService))
                };
                #endregion

                loadContent(content);

                ScreenManager.Game.ResetElapsedTime();
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GravitySensor"/> class.
        /// </summary>
        /// <param name="world">The World object.</param>
        /// <param name="debugViewXNA">The DebugViewXNA object.</param>
        /// <param name="content">The ContentManager object.</param>
        /// <param name="graphics">The GraphicsDeviceManager object.</param>
        /// <param name="position">The initial position of the sensor.</param>
        /// <param name="radius">The radius of the sensor's shape.</param>
        /// <param name="density">The density of the sensor.</param>
        /// <param name="strength">The gravity strength of the sensor.</param>
        /// <param name="minRadius">The minimum radius the gravity can affect.</param>
        /// <param name="maxRadius">The maximum radius the gravity can affect.</param>
        /// <param name="effect">The ParticleEffect for the sensor.</param>
        /// <param name="screenManager">The ScreenManager object.</param>
        public GravitySensor(World world,
                DebugViewXNA debugViewXNA,
                ContentManager content,
                GraphicsDeviceManager graphics,
                Vector2 position,
                float radius,
                float density,
                float strength,
                float minRadius,
                float maxRadius,
                ScreenManager.ScreenManager screenManager
             )
            : base(world,
                debugViewXNA,
                content,
                graphics,
                position,
                radius,
                density,
                strength,
                minRadius,
                maxRadius)
        {
            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleManager = new ParticleEffectManager(this.mParticleRenderer);
            this.mEmitter = new CircleEmitter
            {
                Radius = this.mRadius,
                Ring = true,
                Radiate = true,
                Budget = 500,
                ReleaseColour = new VariableFloat3 { Value = new Vector3(0, 1, 1), Variation = new Vector3(0, 0, 0) },
                ReleaseQuantity = 4,
                ReleaseImpulse = new Vector2(0, 0),
                ReleaseOpacity = new VariableFloat { Value = 1f, Variation = 0f },
                ReleaseRotation = new VariableFloat { Value = 3.14f, Variation = 3.14f },
                ReleaseSpeed = new VariableFloat { Value = 50f, Variation = 25f },
                ReleaseScale = new VariableFloat { Value = 48f, Variation = 32f },
                BlendMode = EmitterBlendMode.Add,
                Term = 0.9f,
                MinimumTriggerPeriod = 0f
            };

            this.mEmitter.ParticleTexture = mContent.Load<Texture2D>(@"Textures\LensFlare");

            this.mEmitter.Modifiers.Add(new ColourModifier
            {
                InitialColour = Color.White.ToVector3(),
                UltimateColour = Color.Aqua.ToVector3()
            });

            this.mEmitter.Modifiers.Add(new RotationRateModifier
            {
                InitialRate = 10f,
                FinalRate = 1f
            });

            this.mEmitter.Modifiers.Add(new OpacityInterpolatorModifier
            {
                InitialOpacity = 0f,
                MiddleOpacity = 0.15f,
                MiddlePosition = 0.7f,
                FinalOpacity = 0f
            });

            this.mParticleEffect = new ParticleEffect { this.mEmitter };
            this.mParticleEffect.Initialise();

            this.mParticleManager.Add(this.mParticleEffect);
            this.mParticleRenderer.LoadContent(this.mContent);
            this.mParticleEffect.LoadContent(this.mContent);

            this.mParticleEnabled = true;

            this.mWorld.ContactManager.BeginContact += BeginContact;
            this.mWorld.ContactManager.EndContact += EndContact;

            this.mInfo = new SensorInfoText(this.mContent,
                this.mGraphics,
                ConvertUnits.ToDisplayUnits(this.mPosition),
                Color.White);
        }
Esempio n. 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GravitySensor"/> class.
        /// </summary>
        /// <param name="world">The World object.</param>
        /// <param name="debugViewXNA">The DebugViewXNA object.</param>
        /// <param name="content">The ContentManager object.</param>
        /// <param name="graphics">The GraphicsDeviceManager object.</param>
        /// <param name="position">The initial position of the sensor.</param>
        /// <param name="radius">The radius of the sensor's shape.</param>
        /// <param name="density">The density of the sensor.</param>
        /// <param name="strength">The gravity strength of the sensor.</param>
        /// <param name="minRadius">The minimum radius the gravity can affect.</param>
        /// <param name="maxRadius">The maximum radius the gravity can affect.</param>
        /// <param name="effect">The ParticleEffect for the sensor.</param>
        /// <param name="screenManager">The ScreenManager object.</param>
        public GravitySensor(World world,
                DebugViewXNA debugViewXNA,
                ContentManager content,
                GraphicsDeviceManager graphics,
                Vector2 position,
                float radius,
                float density,
                float strength,
                float minRadius,
                float maxRadius,
                ParticleEffect effect,
                ScreenManager.ScreenManager screenManager
             )
            : base(world,
                debugViewXNA,
                content,
                graphics,
                position,
                radius,
                density,
                strength,
                minRadius,
                maxRadius)
        {
            this.mParticleEffect = effect;

            this.mParticleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = this.mGraphics
            };

            this.mParticleManager = new ParticleEffectManager(this.mParticleRenderer);

            this.mParticleManager.Add(this.mParticleEffect);
            this.mParticleEffect.LoadContent(this.mContent);
            this.mParticleEffect.Initialise();
            this.mParticleRenderer.LoadContent(this.mContent);

            this.mParticleEnabled = true;

            this.mWorld.ContactManager.BeginContact += BeginContact;
            this.mWorld.ContactManager.EndContact += EndContact;

            this.mInfo = new SensorInfoText(this.mContent,
                this.mGraphics,
                ConvertUnits.ToDisplayUnits(this.mPosition),
                Color.White);
        }
Esempio n. 22
0
        public static void Initialize(GraphicsDeviceManager graphics, ContentManager Content)
        {
            pContent = Content;
            effects = new Dictionary<string, ParticleEffect>();
            shaders = new Dictionary<string, Microsoft.Xna.Framework.Graphics.Effect>();
            animations = new List<ShaderAnimation>();

            pRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };
        }
Esempio n. 23
0
        public GOEffect(GraphicsDeviceManager _graphics, ContentManager _Content, string _fileName)
        {
            graphics = _graphics;
            Content = _Content;

            renderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics };
            effect = new ParticleEffect();
            fileName = _fileName;

            effect = Content.Load<ParticleEffect>(fileName);
            effect.LoadContent(Content);
            effect.Initialise();
            renderer.LoadContent(Content);
            Visible = true;
        }
Esempio n. 24
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Create new renderer and set its graphics devide to "this" device
            myRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics
            };
            myEffect = new ParticleEffect();

            //graphics.IsFullScreen = true;

            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;
        }
Esempio n. 25
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            #region paticle initial
            particleEffect = new ParticleEffect
            {
                new Emitter
                {
                    Budget = 1000,
                    Term = 3f,

                    Name = "FirstEmitter",
                    BlendMode = EmitterBlendMode.Alpha,
                    ReleaseQuantity = 3,
                    ReleaseRotation = new VariableFloat{Value = 0f, Variation = MathHelper.PiOver2},
                    ReleaseSpeed = new VariableFloat{Value = 64f, Variation = 32f},
                    ReleaseScale = 48f,

                    ParticleTextureAssetName = "images\\smoke",

                    Modifiers = new ModifierCollection
                    {
                        new OpacityModifier
                        {
                            Initial = 1f,
                            Ultimate = 0f,
                        },
                        new ColourModifier
                        {
                            InitialColour = Color.DarkRed.ToVector3(),
                            UltimateColour = Color.YellowGreen.ToVector3(),
                        },
                    },
                },
            };

            particleRenderer = new SpriteBatchRenderer
            {
                GraphicsDeviceService = graphics,
            };
            #endregion

            rnd = new Random();

            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferredBackBufferWidth = 1024;
        }