示例#1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     Locator.Init(this, graphics.GraphicsDevice, Content, Content.Load <SpriteFont>("Arial"));
     _spriteBatchService = Locator.Get <ISpriteBatchService>();
     base.Initialize();
 }
        /// <summary>
        /// Create an empty world.
        /// </summary>
        /// <param name="parentScreen">The screen this world will be updated in.</param>
        public World(Screen parentScreen, Player player)
            : base(parentScreen)
        {
            this.worldObjects = new List<WorldObject>();
            this.player = player;
            ParentScreen.Components.Add(player);
            this.interactiveLayers = new Dictionary<int, TileMapLayer>();
            this.parallaxLayers = new Dictionary<int, TileMapLayer>();
            batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));
            otherMaps = new List<TileMap>();

            //Set up Sound systems
            audioEngine = new AudioEngine("Content\\System\\Sounds\\Win\\SoundFX.xgs");
            soundBank = new SoundBank(audioEngine, "Content\\System\\Sounds\\Win\\GameSoundBank.xsb");
            waveBank = new WaveBank(audioEngine, "Content\\System\\Sounds\\Win\\GameWavs.xwb");

            // Set up our collision systems:
            spriteCollisionManager = new SpriteSpriteCollisionManager(this.Game, batchService, 40, 40);
            ParentScreen.Components.Add(spriteCollisionManager);

            bgm = this.Game.Content.Load<Song>("System\\Music\\DesertBGM");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(bgm);

            LoadCtorInfos();
        }
示例#3
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)BaseGame.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch spriteBatch = spriteBatchService.SpriteBatch;

            spriteBatch.Begin();
            spriteBatch.DrawString(defaultFont, "Rpg Plugin Enabled", new Vector2(620, 570), Color.Black);
            spriteBatch.End();
        }
示例#4
0
        /// <summary>
        /// overriden from DrawableGameComponent, Draw will use ParticleSampleGame's
        /// sprite batch to render all of the active particles.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)Game.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch spriteBatch = spriteBatchService.SpriteBatch;

            // tell sprite batch to begin, using the spriteBlendMode specified in
            // initializeConstants
            spriteBatch.Begin(SpriteSortMode.Deferred, blendState); // 4.0change

            foreach (Particle p in particles)
            {
                // skip inactive particles
                if (!p.Active)
                {
                    continue;
                }

                // normalized lifetime is a value from 0 to 1 and represents how far
                // a particle is through its life. 0 means it just started, .5 is half
                // way through, and 1.0 means it's just about to be finished.
                // this value will be used to calculate alpha and scale, to avoid
                // having particles suddenly appear or disappear.
                float normalizedLifetime = p.TimeSinceStart / p.Lifetime;


                // we want particles to fade in and fade out, so we'll calculate alpha
                // to be (normalizedLifetime) * (1-normalizedLifetime). this way, when
                // normalizedLifetime is 0 or 1, alpha is 0. the maximum value is at
                // normalizedLifetime = .5, and is
                // (normalizedLifetime) * (1-normalizedLifetime)
                // (.5)                 * (1-.5)
                // .25
                // since we want the maximum alpha to be 1, not .25, we'll scale the
                // entire equation by 4.
                float alpha = 4 * normalizedLifetime * (1 - normalizedLifetime);
                Color color = p.Color;
                color.A = (byte)(255 * alpha);

                // make particles grow as they age. they'll start at 75% of their size,
                // and increase to 100% once they're finished.
                float scale = p.Scale * (.75f + .25f * normalizedLifetime);

                spriteBatch.Draw(texture, p.Position, null, color,
                                 p.Rotation, origin, scale, SpriteEffects.None, 0.0f);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
        public SpriteSpriteCollisionManager(Game game, ISpriteBatchService spriteBatch, int binWidth, int binHeight)
            : base(game)
        {
            this.registeredObject = new List<ISpriteCollideable>();
            this.objectBinsToCheck = new List<CollisionObjectBin>();
            this.objBinLookupTable = new Dictionary<int, List<Point>>();
            this.refSpriteBatch = spriteBatch.GetSpriteBatch("Camera Sensitive");

            this.binWidth = binWidth;
            this.binHeight = binHeight;
            this.gridWidth = 0;
            this.gridHeight = 0;
            offsetVector = new Vector2();
            // Set this to add more bins out side of camera size
            bufferBins = 10;
        }
示例#6
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)Game.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch spriteBatch = spriteBatchService.SpriteBatch;

            spriteBatch.Begin();

            spriteBatch.DrawString(textFont, "Yellow - Skills", new Vector2(50, 550), Color.Black);
            spriteBatch.DrawString(textFont, "Yellow - Skills", new Vector2(52, 551), Color.Yellow);
            spriteBatch.DrawString(textFont, "Blue - Tasks", new Vector2(630, 550), Color.Black);
            spriteBatch.DrawString(textFont, "Blue - Tasks", new Vector2(632, 551), Color.Yellow);

            spriteBatch.End();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        public override void Initialize()
        {
            if (!this.IsInitialized)
            {
                tileEngine = new TileEngine();

                // CreateSprites needs the animation data service
                // animationDataService = (IAnimationDataService)this.Game.Services.GetService(typeof(IAnimationDataService));
                batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));

                CreateLayerComponents();

                CreateSprites();

                //CreateDebuggingInformationComponents();

                // Initialize all components
                base.Initialize();
            }
        }
示例#8
0
        public override void Draw(GameTime gameTime)
        {
            IPlayerService playerService =
                (IPlayerService)Game.Services.GetService(typeof(IPlayerService));
            NoteManager notes = playerService.Notes;

            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)Game.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch spriteBatch = spriteBatchService.SpriteBatch;

            // generate the lightning stuff first
            Matrix world = Matrix.Identity * Matrix.CreateScale(0.25f) * Matrix.CreateRotationX(rotation);

            for (int i = 0; i < itemCount; i++)
            {
                if (long_pressed_vis[i])
                {
                    long_pressed[i].GenerateTexture(gameTime, world, view, projection);
                }
            }

            // Draw background
            spriteBatch.Begin(0, BlendState.AlphaBlend); // 4.0change
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            spriteBatch.End();

            // 4.0changesx3
            GraphicsDevice.BlendState        = BlendState.AlphaBlend;
            GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead; // 4.0change; esp this one
            //GraphicsDevice.VertexDeclaration = colorDeclaration; // 4.0change AND THIS ONE! Should do SetSource(vertexBuffer) ?

            // btftest
            DrawNeck();
            DrawBars(playerService, notes);
            DrawStrings();
            DrawNotes(notes);
            DrawHitBoxes();
            DrawLongHitNotes(playerService, spriteBatch);
        }
        /// <summary>
        /// Load a world from an XML file.
        /// </summary>
        /// <param name="parentScreen">The screen this world will be updated in.</param>
        /// <param name="fileName">The name of the XML file that contains this World's information.</param>
        public World(Screen parentScreen, string fileName)
            : base(parentScreen)
        {
            this.worldObjects = new List<WorldObject>();
            this.interactiveLayers = new Dictionary<int, TileMapLayer>();
            this.parallaxLayers = new Dictionary<int, TileMapLayer>();
            batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));
            otherMaps = new List<TileMap>();

            // Set up our collision systems:
            spriteCollisionManager = new SpriteSpriteCollisionManager(this.Game, batchService, 40, 40);
            ParentScreen.Components.Add(spriteCollisionManager);

            //Set up Sound systems
            audioEngine = new AudioEngine("Content\\System\\Sounds\\SoundFX.xgs");
            soundBank = new SoundBank(audioEngine, "Content\\System\\Sounds\\GameSoundBank.xsb");
            waveBank = new WaveBank(audioEngine, "Content\\System\\Sounds\\GameWavs.xwb");

            bgm = this.Game.Content.Load<Song>("System\\Music\\DesertBGM");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(bgm);

            // The spritebatch to be used when creating all of our worldObjects:
            spriteBatch = batchService.GetSpriteBatch(Character.SpriteBatchName);
            LoadCtorInfos();

            // Load the contents of the world from the specified XML file:
            LoadWorldXmlFile(fileName);
        }
示例#10
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)Game.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch      spriteBatch = spriteBatchService.SpriteBatch;
            int              y           = 160;
            List <Texture2D> textures    = skillManager.ActiveSkillTextures;
            int              num         = textures.Count;
            int              id          = 1;

            spriteBatch.Begin();

            // Without this, skills are displayed OVER THE MENU SCREENS!
            if (state == RhythmGame.GameStateType.Running)
            {
                foreach (Texture2D texture in skillManager.ActiveSkillTextures)
                {
                    double truePercent = ((float)id / (float)num);
                    double percent     = truePercent * 0.5 + 0.5;
                    Color  pixColor    = Color.White;
                    pixColor.A = (byte)(truePercent * 255);
                    spriteBatch.Draw(texture, new Vector2(650, y), null, pixColor, 0.0f, Vector2.Zero, (float)(percent * .25f), SpriteEffects.None, 1.0f);
                    y += 15;
                    id++;
                }

                time = Notes.SongTime.ToString();
                int index = (time.LastIndexOf(":") - 2);
                if ((index + 7 <= time.Length) && (index > 0))
                {
                    spriteBatch.DrawString(menuFont, time.Substring(index, 7), new Vector2(10, 520), Color.White);
                }

                int x = 40;
                //SkillTextures
                Dictionary <string, Skill> skills = skillManager.Skills;
                foreach (KeyValuePair <string, Skill> pair in skills)
                {
                    Color pixColor = Color.White;
                    int   numTimes = 0;
                    if (!readiedSkills.Contains(pair.Value) && !pair.Value.OnGoing)
                    {
                        pixColor.A = 100;
                    }
                    else if (readiedSkills.Contains(pair.Value))
                    {
                        numTimes = readiedSkillCounts[pair.Key];
                    }
                    Texture2D texture = skillManager.SkillTextures[pair.Key];
                    spriteBatch.Draw(texture, new Vector2(x, 50), null, pixColor, 0.0f, Vector2.Zero, (float)(.15f), SpriteEffects.None, 1.0f);
                    if (!pair.Value.OnGoing)
                    {
                        spriteBatch.DrawString(spriteFont, "" + numTimes, new Vector2(x, 50), pixColor);
                    }

                    x += 95;
                }
            }
            spriteBatch.End();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        public override void Initialize()
        {
            if (!this.IsInitialized)
            {
                tileEngine = new TileEngine();

                fullScreenSettings = new ResolutionSettings(640, 480, 640,
                                                                      480,
                                                                      true);

                ScreenManager.Instance.ResolutionService.CurrentResolutionSettings = windowedSettings;

                batchService = (ISpriteBatchService)this.Game.Services.GetService(typeof(ISpriteBatchService));

                // Create a new, empty world:
                world = new World(this, WORLD_FILENAME);

                // We need to disable the SpriteSpriteCollisionManager because it makes some assumptions about
                //  the gameScreen...
                world.SpriteCollisionManager.Enabled = false;

                // Create an empty, maximally-sized tilemap to center
                //  the loaded map onto:
                TileMap bigMap = new TileMap(MAX_TILEMAP_WIDTH, MAX_TILEMAP_HEIGHT,
                                          DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT,
                                          LAYER_COUNT, SUB_LAYER_COUNT);
                bigMap.FileName = world.Map.FileName;

                // Backup the original map:
                TileMap map = world.Map;

                // Compute the point where we want to blit it onto the empty map:
                this.offsetX = (bigMap.Width / 2) - (map.Width / 2);
                this.offsetY = (bigMap.Height / 2) - (map.Height / 2);

                bigMap.BlitTileMap(map, offsetX, offsetY);

                world.Map = bigMap;
                foreach (TileMapLayer tml in world.interactiveLayers.Values)
                {
                    Components.Remove(tml);
                }
                world.interactiveLayers.Clear();
                world.ShiftWorldObjects(new Vector2(world.Map.TileWidth * offsetX, world.Map.TileWidth * offsetY));

                for (int i = 0; i < world.Map.LayerCount; ++i)
                {
                    TileMapLayer tml = new TileMapLayer(this, batchService.GetSpriteBatch(TileMapLayer.SpriteBatchName), world.Map, i);
                    if (i == 0)
                    {
                        tml.DrawOrder = World.PLAYER_DRAW_ORDER - DEFAULT_LAYER_SPACING;
                    }
                    else
                    {
                        if (i == world.Map.LayerCount - 1)
                        {
                            tml.DrawBlanksEnabled = true;
                            tml.DrawEdgesEnabled = true;
                            tml.DrawDestructablesEnabled = true;
                        }
                        tml.DrawOrder = World.PLAYER_DRAW_ORDER + i * DEFAULT_LAYER_SPACING;
                    }
                    world.interactiveLayers[tml.DrawOrder] = tml;
                    Components.Add(world.interactiveLayers[tml.DrawOrder]);
                }

                world.Initialize();
                world.Camera.Position = world.Player.Position;// -new Vector2(world.Camera.VisibleArea.Width / 2, world.Camera.VisibleArea.Height / 2);
                world.Paused = true;

                Components.Add(world);

                // Set up editor controls:
                inputMonitor = InputMonitor.Instance;
                inputMonitor.AssignPressable("EditorLeft", new PressableKey(Keys.A));
                inputMonitor.AssignPressable("EditorRight", new PressableKey(Keys.D));
                inputMonitor.AssignPressable("EditorUp", new PressableKey(Keys.W));
                inputMonitor.AssignPressable("EditorDown", new PressableKey(Keys.S));
                inputMonitor.AssignPressable("EditorAppend", new PressableKey(Keys.LeftShift));
                inputMonitor.AssignPressable("ToggleFullScreen", new PressableKey(Keys.F));
                inputMonitor.AssignPressable("EditorCycleMode", new PressableKey(Keys.Tab));
                Components.Add(inputMonitor);

                CreateUIComponents();

                Mode = EditMode.SpriteEdit;
                CycleMode();

                // Initialize all components
                base.Initialize();
            }
        }
示例#12
0
 public DrawableService(ISpriteBatchService spriteBatchService)
 {
     _spriteBatchService = spriteBatchService;
 }
示例#13
0
        public override void Draw(GameTime gameTime)
        {
            if (((RhythmGame)Game).State != RhythmGame.GameStateType.Running &&
                ((RhythmGame)Game).State != RhythmGame.GameStateType.Paused)
            {
                return;
            }

            ISpriteBatchService spriteBatchService =
                (ISpriteBatchService)Game.Services.GetService(typeof(ISpriteBatchService));
            SpriteBatch spriteBatch = spriteBatchService.SpriteBatch;

            spriteBatch.Begin(0, BlendState.AlphaBlend); // 4.0change

            int width  = GraphicsDevice.Viewport.Width;
            int height = GraphicsDevice.Viewport.Height;

            spriteBatch.DrawString(titleFont, "X" + multiplier, new Vector2((float)(width * 0.8), 400), Color.Wheat);
            int barHeight = (int)(healthBack.Height * (health / health_max));

            if (health > (health_max / 3.0))
            {
                spriteBatch.Draw(healthBack, new Rectangle((int)(width * 0.1), 500 - barHeight, healthBack.Width, barHeight), Color.Lime);
            }
            else
            {
                spriteBatch.Draw(lowHealthBack, new Rectangle((int)(width * 0.1), 500 - barHeight, healthBack.Width, barHeight), Color.Lime);
            }
            spriteBatch.Draw(healthBox, new Rectangle((int)(width * 0.1), 500 - healthBox.Height, healthBox.Width, healthBox.Height), Color.White);
            //spriteBatch.DrawString(spriteFont, "" + health, new Vector2((float)(width*0.1), 550), Color.Wheat);
            spriteBatch.DrawString(largeMenuFont, "" + score, new Vector2((float)(width * 0.7), 300), Color.Wheat);

            // player is doing really good, smoke will rise!
            if (multiplier > 3)
            {
                Vector2 pos = new Vector2((int)(width * 0.1), 500 - healthBox.Height);
                smoke.AddParticles(pos, Color.White);
            }

            // Check star levels...
            if (Notes != null)
            {
                uint[] starLevels = Notes.StarLevels;
                int    stars      = starLevels.Length;
                uint   lastLevel  = 0;
                uint   starIdx    = 0;
                for (int i = 0; i < stars; i++)
                {
                    // Are we good enough...?
                    Vector2 starPos       = new Vector2(50 + starIdx * 150, 30);
                    Color   slightlyClear = Color.White;
                    float   scoreMax      = (float)(starLevels[i] - lastLevel);
                    float   scorePart     = (float)(score - lastLevel);

                    if (starLevels[i] == 0)
                    {
                        continue;
                    }
                    starIdx++;

                    if (score > starLevels[i])
                    {
                        spriteBatch.Draw(starTexture, starPos, null, Color.White, 0.0F, Vector2.Zero, 1.0F, SpriteEffects.None, 1.0F);
                        this.stars = starIdx;
                    }
                    else
                    {
                        slightlyClear.A = (byte)((scorePart / scoreMax) * 255);
                        spriteBatch.Draw(starTexture, starPos, null, slightlyClear, 0.0F, Vector2.Zero, 1.0F, SpriteEffects.None, 1.0F);
                        break;
                    }
                    lastLevel = starLevels[i];
                }
            }

            // Our replacement for scoring different stars on a song...
            // if we're
            //spriteBatch.DrawString(titleFont, "Wicked", new Vector2((float)(width * 0.2), 50), Color.Wheat);
            //Oh noes!
            //Beat-up
            //Bite
            //Bogus
            //Heinous
            //Nasty
            //Weak
            //Sad
            //Tired
            //Chump
            //Yuk
            //Jacked up
            //Fake
            //Crummy
            //Faulty
            //Crap
            //Aight
            //All Good
            //Freakin' Awesome
            //Perfect!
            //Butter
            //Cherry
            //Chill
            //Choice
            //Cool
            //Fly
            //Golden
            //A-1
            //Gravy
            //Hot
            //Killer
            //Nice
            //Pimp
            //Primo
            //Sick
            //Spiffy
            //Stellar
            //Styling
            //Sweet
            //Tight
            //Wicked

            spriteBatch.End();
        }
示例#14
0
 /// <summary>
 /// Draw a texture
 /// </summary>
 /// <param name="texture">Texture to draw</param>
 /// <param name="position">Position of the texture</param>
 /// <param name="color">Global color</param>
 public static void Draw(this ISpriteBatchService batch, Texture texture, Vector position, Color color)
 {
     batch.Draw(texture, position, null, color, 0f, Vector.Zero, 1.0f);
 }
示例#15
0
 /// <summary>
 /// Draw the specified texture.
 /// </summary>
 /// <param name="texture">Texture.</param>
 /// <param name="destination">Destination.</param>
 /// <param name="color">Color.</param>
 public static void Draw(this ISpriteBatchService batch, Texture texture, Rectangle destination, Color color)
 {
     batch.Draw(texture, destination, null, color);
 }
示例#16
0
 /// <summary>
 /// Draw the specified texture.
 /// </summary>
 /// <param name="texture">Texture.</param>
 /// <param name="destination">Destination.</param>
 /// <param name="source">Source.</param>
 /// <param name="color">Color.</param>
 public static void Draw(this ISpriteBatchService batch, Texture texture, Rectangle destination, Rectangle source, Color color)
 {
     batch.Draw(texture, destination, source, color, 0f, Vector.Zero);
 }