public override void Initialize()
        {
            Texture2D texture = new Texture2D(GraphicsDevice, 10, 10);

            texture.SetData(Enumerable.Repeat(Color.Green, texture.Width * texture.Height).ToArray());

            _particleEngine = new ParticleEngine2D(Game, new List <Texture2D> {
                texture
            });
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            cDrawBatch = new SpriteBatch(cGraphDevMgr.GraphicsDevice);

            cSolidTexture = new Texture2D(cGraphDevMgr.GraphicsDevice, 1, 1);
            //cSolidTexture.SetData (new[] { new Color(255, 255, 255, 100) });
            //cSolidTexture.SetData (new[] { new Color(0, 0, 0, 100) });
            cSolidTexture.SetData(new[] { Color.White });

            foreach (Textures CurrTexture in Enum.GetValues(typeof(Textures)))
            {
                cTextureDict.Add(CurrTexture, Content.Load <Texture2D>(Tools.EnumTools.GetEnumDescriptionAttribute(CurrTexture)));
            }

            //cShader = Content.Load<Effect>("ShaderEffect");
            //cShipShader = Content.Load<Effect>("BumpMap");
            //cShipShader.Parameters["NormalMap"].SetValue(cTextureDict[Textures.ShipNormal]);

            cFont                    = new TextureFont(cTextureDict[Textures.Font]);
            cDevConsole              = new MDLN.MGTools.GameConsole(cGraphDevMgr.GraphicsDevice, Content, Content.RootDirectory + "\\Font.png", 0, 0, cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Width, cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Height / 2);
            cDevConsole.CommandSent += CommandSentEventHandler;
            cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
            cDevConsole.CloseEffect  = DisplayEffect.SlideUp;

            cPlayerShip = new Ship(cGraphDevMgr.GraphicsDevice, 50);
            cPlayerShip.BackgroundColor = new Color(100, 100, 100, 0);             //Set background completely transparent
            cPlayerShip.ShipTexture     = cTextureDict[Textures.Ship];
            cPlayerShip.Visible         = true;
            cPlayerShip.Top             = cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Height / 2;
            cPlayerShip.Left            = cGraphDevMgr.GraphicsDevice.Viewport.Bounds.Width / 2;
            //cPlayerShip.ImageInitialAngle = 1.570796f; //Offset for image pointing up instead of right
            cPlayerShip.MouseRotate = true;

            cPlayerBullets = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
            cPlayerBullets.DrawBlendingMode = BlendState.Additive;
            //cPlayerBullets.ShaderEffect = cShader;

            cEnemyBullets = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
            cEnemyBullets.DrawBlendingMode = BlendState.Additive;

            cAsteroids = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
            cAsteroids.WrapScreenEdges = true;

            cUFOs = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
            //cUFOs.ShaderEffect = cShipShader;
            cUFOs.WrapScreenEdges = true;

            cSparkles = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);
            cSparkles.DrawBlendingMode = BlendState.Additive;
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            List <Texture2D> textures = new List <Texture2D>
            {
                Game.Content.Load <Texture2D>("particle/star")
            };

            _particleEngine = new ParticleEngine2D(Game, textures);

            _particleEngine = new ParticleEngine2D(Game, textures);
            _particleEngine.GravitationEnabled       = true;
            _particleEngine.StartVelocityMultiplyMin = -2;
            _particleEngine.StartVelocityMultiplyMax = 2;
            _particleEngine.StartLifeTimeMin         = TimeSpan.FromSeconds(5);
            _particleEngine.StartLifeTimeMax         = TimeSpan.FromSeconds(10);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            PhysicalObject NewObj;

            //The font texture isn't needed, but this is an example of loading a PNG
            string     strFileName = INTERFACECONTENTDIR + "Font.png";
            FileStream FileLoad    = new FileStream(strFileName, FileMode.Open);
            Texture2D  FontTexture = Texture2D.FromStream(GraphicsDevice, FileLoad);

            FileLoad.Close();

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, INTERFACECONTENTDIR + "Font.png", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandHandler);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cTextureAtlas = new TextureAtlas(cGraphDevMgr.GraphicsDevice, INTERFACECONTENTDIR + "spaceShooter2_spritesheet.png", INTERFACECONTENTDIR + "spaceShooter2_spritesheet.xml");
            cObjManager   = new ObjectManager(cGraphDevMgr.GraphicsDevice, cTextureAtlas, INTERFACECONTENTDIR + "GameObjects.xml");
            cParticles    = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);

            //Plaeyer's object
            NewObj = cObjManager.SpawnGameObject("ship01", (int)eObjGroups_t.Player);

            NewObj.SetPosition(new Vector2(128, 128), new Vector2(0.25f, 0.25f), 0);
            NewObj.Updating += UserShipUpdating;

            cPlayer.nMaxSpeed = 12;

            return;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load all external content files that are needed
        /// </summary>
        protected override void LoadContent()
        {
            String      strFileName;
            Texture2D   NewTexture;
            TextureFont Font = new TextureFont();
            FileStream  FileLoad;

            strFileName      = INTERFACECONTENTDIR + "\\Font.png";
            FileLoad         = new FileStream(strFileName, FileMode.Open);
            NewTexture       = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, FileLoad);
            Font.FontTexture = NewTexture;
            FileLoad.Close();

            try {
                cDevConsole              = new GameConsole(cGraphDevMgr.GraphicsDevice, Content, INTERFACECONTENTDIR + "\\Font.png", cGraphDevMgr.GraphicsDevice.Viewport.Width, cGraphDevMgr.GraphicsDevice.Viewport.Height / 2);
                cDevConsole.AccessKey    = Keys.OemTilde;
                cDevConsole.UseAccessKey = true;
                cDevConsole.OpenEffect   = DisplayEffect.SlideDown;
                cDevConsole.CloseEffect  = DisplayEffect.SlideUp;
                cDevConsole.CommandSent += new CommandSentEventHandler(ConsoleCommandHandler);
            } catch (Exception ExErr) {
                System.Windows.Forms.MessageBox.Show("Failed to initialize console: " + ExErr.GetType().ToString() + " - " + ExErr.Message);
                Exit();
                return;
            }

            cSettingsCont                 = new MDLN.MGTools.Container(GraphicsDevice, GraphicsDevice.Viewport.Height, 300);
            cSettingsCont.Width           = 300;
            cSettingsCont.Height          = GraphicsDevice.Viewport.Height;
            cSettingsCont.Visible         = true;
            cSettingsCont.BackgroundColor = new Color(Color.White, 0.5f);
            cSettingsCont.Top             = 0;
            cSettingsCont.Left            = 0;

            cShowingLbl                 = new Button(GraphicsDevice, null, 10, 10, 20, 280);
            cShowingLbl.Text            = "";
            cShowingLbl.Visible         = true;
            cShowingLbl.Font            = Font;
            cShowingLbl.BackgroundColor = Color.Transparent;
            cShowingLbl.FontColor       = LBLTEXTCOLOR;

            cAddParitclesBtn                 = new Button(GraphicsDevice, null, 40, 10, 20, 280);
            cAddParitclesBtn.Text            = "Add Particles";
            cAddParitclesBtn.Visible         = true;
            cAddParitclesBtn.Font            = Font;
            cAddParitclesBtn.BackgroundColor = Color.LightGray;
            cAddParitclesBtn.FontColor       = Color.Black;
            cAddParitclesBtn.Click          += AddParticlesClickHandler;

            cNumParticlesLbl                 = new Button(GraphicsDevice, null, 70, 10, 20, 105);
            cNumParticlesLbl.Text            = "Add Amount";
            cNumParticlesLbl.Visible         = true;
            cNumParticlesLbl.Font            = Font;
            cNumParticlesLbl.BackgroundColor = Color.Transparent;
            cNumParticlesLbl.FontColor       = LBLTEXTCOLOR;

            cNumParticlesTxt                 = new TextBox(GraphicsDevice, null, 70, 125, 20, 165);
            cNumParticlesTxt.Text            = "1";
            cNumParticlesTxt.Visible         = true;
            cNumParticlesTxt.Font            = Font;
            cNumParticlesTxt.BackgroundColor = Color.Black;
            cNumParticlesTxt.FontColor       = Color.White;
            cNumParticlesTxt.Alignment       = Justify.MiddleCenter;

            cHeightLbl                 = new Button(GraphicsDevice, null, 100, 10, 20, 90);
            cHeightLbl.Text            = "Height";
            cHeightLbl.Visible         = true;
            cHeightLbl.Font            = Font;
            cHeightLbl.BackgroundColor = Color.Transparent;
            cHeightLbl.FontColor       = LBLTEXTCOLOR;

            cHeightMinTxt                 = new TextBox(GraphicsDevice, null, 100, 100, 20, 90);
            cHeightMinTxt.Text            = "64";
            cHeightMinTxt.Visible         = true;
            cHeightMinTxt.Font            = Font;
            cHeightMinTxt.BackgroundColor = Color.Black;
            cHeightMinTxt.FontColor       = Color.White;
            cHeightMinTxt.Alignment       = Justify.MiddleCenter;

            cHeightMaxTxt                 = new TextBox(GraphicsDevice, null, 100, 200, 20, 90);
            cHeightMaxTxt.Text            = "64";
            cHeightMaxTxt.Visible         = true;
            cHeightMaxTxt.Font            = Font;
            cHeightMaxTxt.BackgroundColor = Color.Black;
            cHeightMaxTxt.FontColor       = Color.White;
            cHeightMaxTxt.Alignment       = Justify.MiddleCenter;

            cWidthLbl                 = new Button(GraphicsDevice, null, 130, 10, 20, 90);
            cWidthLbl.Text            = "Width";
            cWidthLbl.Visible         = true;
            cWidthLbl.Font            = Font;
            cWidthLbl.BackgroundColor = Color.Transparent;
            cWidthLbl.FontColor       = LBLTEXTCOLOR;

            cWidthMinTxt                 = new TextBox(GraphicsDevice, null, 130, 100, 20, 90);
            cWidthMinTxt.Text            = "64";
            cWidthMinTxt.Visible         = true;
            cWidthMinTxt.Font            = Font;
            cWidthMinTxt.BackgroundColor = Color.Black;
            cWidthMinTxt.FontColor       = Color.White;
            cWidthMinTxt.Alignment       = Justify.MiddleCenter;

            cWidthMaxTxt                 = new TextBox(GraphicsDevice, null, 130, 200, 20, 90);
            cWidthMaxTxt.Text            = "64";
            cWidthMaxTxt.Visible         = true;
            cWidthMaxTxt.Font            = Font;
            cWidthMaxTxt.BackgroundColor = Color.Black;
            cWidthMaxTxt.FontColor       = Color.White;
            cWidthMaxTxt.Alignment       = Justify.MiddleCenter;

            cRedLbl                 = new Button(GraphicsDevice, null, 160, 10, 20, 90);
            cRedLbl.Text            = "Red";
            cRedLbl.Visible         = true;
            cRedLbl.Font            = Font;
            cRedLbl.BackgroundColor = Color.Transparent;
            cRedLbl.FontColor       = LBLTEXTCOLOR;

            cRedMinTxt                 = new TextBox(GraphicsDevice, null, 160, 100, 20, 90);
            cRedMinTxt.Text            = "0";
            cRedMinTxt.Visible         = true;
            cRedMinTxt.Font            = Font;
            cRedMinTxt.BackgroundColor = Color.Black;
            cRedMinTxt.FontColor       = Color.White;
            cRedMinTxt.Alignment       = Justify.MiddleCenter;

            cRedMaxTxt                 = new TextBox(GraphicsDevice, null, 160, 200, 20, 90);
            cRedMaxTxt.Text            = "255";
            cRedMaxTxt.Visible         = true;
            cRedMaxTxt.Font            = Font;
            cRedMaxTxt.BackgroundColor = Color.Black;
            cRedMaxTxt.FontColor       = Color.White;
            cRedMaxTxt.Alignment       = Justify.MiddleCenter;

            cGreenLbl                 = new Button(GraphicsDevice, null, 190, 10, 20, 90);
            cGreenLbl.Text            = "Green";
            cGreenLbl.Visible         = true;
            cGreenLbl.Font            = Font;
            cGreenLbl.BackgroundColor = Color.Transparent;
            cGreenLbl.FontColor       = LBLTEXTCOLOR;

            cGreenMinTxt                 = new TextBox(GraphicsDevice, null, 190, 100, 20, 90);
            cGreenMinTxt.Text            = "0";
            cGreenMinTxt.Visible         = true;
            cGreenMinTxt.Font            = Font;
            cGreenMinTxt.BackgroundColor = Color.Black;
            cGreenMinTxt.FontColor       = Color.White;
            cGreenMinTxt.Alignment       = Justify.MiddleCenter;

            cGreenMaxTxt                 = new TextBox(GraphicsDevice, null, 190, 200, 20, 90);
            cGreenMaxTxt.Text            = "255";
            cGreenMaxTxt.Visible         = true;
            cGreenMaxTxt.Font            = Font;
            cGreenMaxTxt.BackgroundColor = Color.Black;
            cGreenMaxTxt.FontColor       = Color.White;
            cGreenMaxTxt.Alignment       = Justify.MiddleCenter;

            cBlueLbl                 = new Button(GraphicsDevice, null, 220, 10, 20, 90);
            cBlueLbl.Text            = "Blue";
            cBlueLbl.Visible         = true;
            cBlueLbl.Font            = Font;
            cBlueLbl.BackgroundColor = Color.Transparent;
            cBlueLbl.FontColor       = LBLTEXTCOLOR;

            cBlueMinTxt                 = new TextBox(GraphicsDevice, null, 220, 100, 20, 90);
            cBlueMinTxt.Text            = "0";
            cBlueMinTxt.Visible         = true;
            cBlueMinTxt.Font            = Font;
            cBlueMinTxt.BackgroundColor = Color.Black;
            cBlueMinTxt.FontColor       = Color.White;
            cBlueMinTxt.Alignment       = Justify.MiddleCenter;

            cBlueMaxTxt                 = new TextBox(GraphicsDevice, null, 220, 200, 20, 90);
            cBlueMaxTxt.Text            = "255";
            cBlueMaxTxt.Visible         = true;
            cBlueMaxTxt.Font            = Font;
            cBlueMaxTxt.BackgroundColor = Color.Black;
            cBlueMaxTxt.FontColor       = Color.White;
            cBlueMaxTxt.Alignment       = Justify.MiddleCenter;

            cLifeLbl                 = new Button(GraphicsDevice, null, 250, 10, 20, 90);
            cLifeLbl.Text            = "Dur mSec";
            cLifeLbl.Visible         = true;
            cLifeLbl.Font            = Font;
            cLifeLbl.BackgroundColor = Color.Transparent;
            cLifeLbl.FontColor       = LBLTEXTCOLOR;

            cLifeMinTxt                 = new TextBox(GraphicsDevice, null, 250, 100, 20, 90);
            cLifeMinTxt.Text            = "1000";
            cLifeMinTxt.Visible         = true;
            cLifeMinTxt.Font            = Font;
            cLifeMinTxt.BackgroundColor = Color.Black;
            cLifeMinTxt.FontColor       = Color.White;
            cLifeMinTxt.Alignment       = Justify.MiddleCenter;

            cLifeMaxTxt                 = new TextBox(GraphicsDevice, null, 250, 200, 20, 90);
            cLifeMaxTxt.Text            = "5000";
            cLifeMaxTxt.Visible         = true;
            cLifeMaxTxt.Font            = Font;
            cLifeMaxTxt.BackgroundColor = Color.Black;
            cLifeMaxTxt.FontColor       = Color.White;
            cLifeMaxTxt.Alignment       = Justify.MiddleCenter;

            cDelayLbl                 = new Button(GraphicsDevice, null, 280, 10, 20, 90);
            cDelayLbl.Text            = "Delay mS";
            cDelayLbl.Visible         = true;
            cDelayLbl.Font            = Font;
            cDelayLbl.BackgroundColor = Color.Transparent;
            cDelayLbl.FontColor       = LBLTEXTCOLOR;

            cDelayMinTxt                 = new TextBox(GraphicsDevice, null, 280, 100, 20, 90);
            cDelayMinTxt.Text            = "0";
            cDelayMinTxt.Visible         = true;
            cDelayMinTxt.Font            = Font;
            cDelayMinTxt.BackgroundColor = Color.Black;
            cDelayMinTxt.FontColor       = Color.White;
            cDelayMinTxt.Alignment       = Justify.MiddleCenter;

            cDelayMaxTxt                 = new TextBox(GraphicsDevice, null, 280, 200, 20, 90);
            cDelayMaxTxt.Text            = "50";
            cDelayMaxTxt.Visible         = true;
            cDelayMaxTxt.Font            = Font;
            cDelayMaxTxt.BackgroundColor = Color.Black;
            cDelayMaxTxt.FontColor       = Color.White;
            cDelayMaxTxt.Alignment       = Justify.MiddleCenter;

            cXDistLbl                 = new Button(GraphicsDevice, null, 310, 10, 20, 90);
            cXDistLbl.Text            = "X Dist";
            cXDistLbl.Visible         = true;
            cXDistLbl.Font            = Font;
            cXDistLbl.BackgroundColor = Color.Transparent;
            cXDistLbl.FontColor       = LBLTEXTCOLOR;

            cXDistMinTxt                 = new TextBox(GraphicsDevice, null, 310, 100, 20, 90);
            cXDistMinTxt.Text            = "-300";
            cXDistMinTxt.Visible         = true;
            cXDistMinTxt.Font            = Font;
            cXDistMinTxt.BackgroundColor = Color.Black;
            cXDistMinTxt.FontColor       = Color.White;
            cXDistMinTxt.Alignment       = Justify.MiddleCenter;

            cXDistMaxTxt                 = new TextBox(GraphicsDevice, null, 310, 200, 20, 90);
            cXDistMaxTxt.Text            = "300";
            cXDistMaxTxt.Visible         = true;
            cXDistMaxTxt.Font            = Font;
            cXDistMaxTxt.BackgroundColor = Color.Black;
            cXDistMaxTxt.FontColor       = Color.White;
            cXDistMaxTxt.Alignment       = Justify.MiddleCenter;

            cYDistLbl                 = new Button(GraphicsDevice, null, 340, 10, 20, 90);
            cYDistLbl.Text            = "Y Dist";
            cYDistLbl.Visible         = true;
            cYDistLbl.Font            = Font;
            cYDistLbl.BackgroundColor = Color.Transparent;
            cYDistLbl.FontColor       = LBLTEXTCOLOR;

            cYDistMinTxt                 = new TextBox(GraphicsDevice, null, 340, 100, 20, 90);
            cYDistMinTxt.Text            = "-300";
            cYDistMinTxt.Visible         = true;
            cYDistMinTxt.Font            = Font;
            cYDistMinTxt.BackgroundColor = Color.Black;
            cYDistMinTxt.FontColor       = Color.White;
            cYDistMinTxt.Alignment       = Justify.MiddleCenter;

            cYDistMaxTxt                 = new TextBox(GraphicsDevice, null, 340, 200, 20, 90);
            cYDistMaxTxt.Text            = "300";
            cYDistMaxTxt.Visible         = true;
            cYDistMaxTxt.Font            = Font;
            cYDistMaxTxt.BackgroundColor = Color.Black;
            cYDistMaxTxt.FontColor       = Color.White;
            cYDistMaxTxt.Alignment       = Justify.MiddleCenter;

            cRotateLbl                 = new Button(GraphicsDevice, null, 370, 10, 20, 90);
            cRotateLbl.Text            = "Rotations";
            cRotateLbl.Visible         = true;
            cRotateLbl.Font            = Font;
            cRotateLbl.BackgroundColor = Color.Transparent;
            cRotateLbl.FontColor       = LBLTEXTCOLOR;

            cRotateMinTxt                 = new TextBox(GraphicsDevice, null, 370, 100, 20, 90);
            cRotateMinTxt.Text            = "-5";
            cRotateMinTxt.Visible         = true;
            cRotateMinTxt.Font            = Font;
            cRotateMinTxt.BackgroundColor = Color.Black;
            cRotateMinTxt.FontColor       = Color.White;
            cRotateMinTxt.Alignment       = Justify.MiddleCenter;

            cRotateMaxTxt                 = new TextBox(GraphicsDevice, null, 370, 200, 20, 90);
            cRotateMaxTxt.Text            = "5";
            cRotateMaxTxt.Visible         = true;
            cRotateMaxTxt.Font            = Font;
            cRotateMaxTxt.BackgroundColor = Color.Black;
            cRotateMaxTxt.FontColor       = Color.White;
            cRotateMaxTxt.Alignment       = Justify.MiddleCenter;

            cRotateAfterBtn                 = new Button(GraphicsDevice, null, 400, 10, 20, 280);
            cRotateAfterBtn.Text            = "Spiral Path";
            cRotateAfterBtn.Visible         = true;
            cRotateAfterBtn.Font            = Font;
            cRotateAfterBtn.BackgroundColor = Color.Red;
            cRotateAfterBtn.FontColor       = Color.Black;
            cRotateAfterBtn.Click          += RotateAfterClickHandler;

            cAlphaFadeBtn                 = new Button(GraphicsDevice, null, 430, 10, 20, 280);
            cAlphaFadeBtn.Text            = "Alpha Fade";
            cAlphaFadeBtn.Visible         = true;
            cAlphaFadeBtn.Font            = Font;
            cAlphaFadeBtn.BackgroundColor = Color.Red;
            cAlphaFadeBtn.FontColor       = Color.Black;
            cAlphaFadeBtn.Click          += AlphaFadeClickHandler;

            foreach (TextureFiles CurrTexture in Enum.GetValues(typeof(TextureFiles)))
            {
                strFileName = INTERFACECONTENTDIR + "\\" + EnumTools.GetEnumDescriptionAttribute(CurrTexture);

                NewTexture = Texture2D.FromStream(cGraphDevMgr.GraphicsDevice, new FileStream(strFileName, FileMode.Open));
                cTextureDict.Add(CurrTexture, NewTexture);
            }

            cSparkles = new ParticleEngine2D(cGraphDevMgr.GraphicsDevice);

            return;
        }