Beispiel #1
0
        public Ship(Texture2D texture, Vector2 location, SpriteBatch spriteBatch)
            : base(texture, location, spriteBatch)
        {
            StateManager.Options.ScreenResolutionChanged += new EventHandler<ViewportEventArgs>(Options_ScreenResolutionChanged);
            _healthBar = new ProgressBar(new Vector2(X, Y), Color.DarkGreen, Color.Red, spriteBatch);
            _healthBar.WidthScale = 1;
            _healthBar.HeightScale = 10;
            Moved += new EventHandler(Ship_Moved);
            _shipID = Guid.NewGuid();
            _initHealth = 100;
            _healthBar.X -= (_healthBar.Width / 2);
            _healthBar.Y -= (_healthBar.Height / 1.5f);

            _isDead = false;

            Explosion = GameContent.Assets.Images.SpriteSheets[SpriteSheetType.Explosion];
            _explosionSheet = new SpriteSheet(GameContent.Assets.Images.SpriteSheets[SpriteSheetType.Explosion], new Rectangle(0, 0, 50, 50), this.Position, spriteBatch, 8, 9);

            _explosionSheet.IsAnimated = true;
            _explosionSheet.Scale = new Vector2(1.5f);
            _explosionSheet.RestartAnimation = false;
            _currentHealth = _initHealth;

            ExplosionSFX = GameContent.Assets.Sound[SoundEffectType.EnemyExplodes];
            FriendlyName = ShipType.ToFriendlyString();

            particles[0] = GameContent.Assets.Images.particles[ParticleType.Circle];
            particles[1] = GameContent.Assets.Images.particles[ParticleType.Square];
            gen = new RandomParticleGenerator(SpriteBatch, particles);
            gen.TTLSettings = TimeToLiveSettings.AlphaLess100;
            gen.RandomProperties = new RandomParticleProperties() { ColorFactor = 0.985f, Tint = Color.White };
            gen.ParticlesToGenerate = 1;
            engine = new Glib.XNA.SpriteLib.ParticleEngine.ParticleEngine(gen);

            Vector2 toEngine = new Vector2(Position.X, Position.Y - texture.Height / 2);
            toEngineLength = -toEngine.Length();
            toEngineAngle = toEngine.ToAngle();

            engine.PositionOffset = new Vector2(0, texture.Height / 2);

            engine.Tracked = this;
        }
Beispiel #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spr = new Sprite(Content.Load<Texture2D>("Jellyfish"), Vector2.Zero, spriteBatch);
            spr.UseCenterAsOrigin = false;
            spr.Scale = new Vector2(.175f);

            ProgressBar progBar = new ProgressBar(new Vector2(55), Color.White, Color.Black, spriteBatch);
            progBar.Scale = new Vector2(.25f);
            progBar.Denominator = 1024;
            progBar.WidthScale = 2;
            progBar.HeightScale = 5;
            progBar.ProgressBarFilled += new EventHandler(progBar_ProgressBarFilled);
            progBar.Value = 0;
            progBar.Updated += new EventHandler(progBar_Updated);

            menuTxt = new TextSprite(spriteBatch, new Vector2(0), Content.Load<SpriteFont>("SpriteFont1"), "Hello world!", Color.Black);
            menuTxt.IsHoverable = true;
            menuTxt.IsSelected = true;
            menuTxt.Pressed += new EventHandler(menuTxt_Clicked);

            menuTxtTwo = new TextSprite(spriteBatch, new Vector2(250,0), Content.Load<SpriteFont>("SpriteFont1"), "Selectable", Color.Black);
            menuTxtTwo.IsHoverable = true;
            //menuTxtTwo.IsManuallySelectable = true;
            //menuTxt.Clicked += new EventHandler(menuTxt_Clicked);
            //menuTxt.HoverColor = Color.Red;

            //KeyboardManager.KeyDown += new SingleKeyEventHandler(KeyboardManager_KeyDown);

            menu = new Screen(new SpriteManager(spriteBatch, progBar), Color.Red);
            menu.AdditionalSprites.Add(menuTxt);
            menu.AdditionalSprites.Add(menuTxtTwo);
            menu.Visible = true;

            menuTwo = new Screen(new SpriteManager(spriteBatch, spr), Color.Gray);

            menus = new ScreenManager(spriteBatch, Color.Pink, menu, menuTwo);
            // TODO: use this.Content to load your game content here
        }
Beispiel #3
0
        void progBar_Updated(object sender, EventArgs e)
        {
            pb = sender.Cast<ProgressBar>();

            pb.Value += pb.Value == pb.Denominator ? 0 : 1;
        }