public void LoadIcons(GraphicsDevice graphics, String bullet_icon, String enemy_icon, ContentManager content, Visualisation vis)
        {
            for (int i = 0; i < m_bullet_count; i++)
            {
                Graphics.Entity.Sprite new_bullet = new Graphics.Entity.Sprite();
                new_bullet.Init(content.Load <Texture2D>(bullet_icon));
                new_bullet.Visible     = false;
                new_bullet.destination = new Rectangle(
                    (int)((((float)graphics.Viewport.Width / 1366.0f) * 175.0f) + (((float)graphics.Viewport.Width / 1366.0f) * 15.0f * i)),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 714.0f),
                    (int)(((float)graphics.Viewport.Width / 1366.0f) * 15.0f),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 47.0f));
                m_bullets.Add(new_bullet);
                vis.AddEntity(new_bullet);
            }

            m_enemy_count = Enemy_Container.enemies().Count;
            for (int i = 0; i < m_enemy_count; i++)
            {
                Graphics.Entity.Sprite new_enemy = new Graphics.Entity.Sprite();
                new_enemy.Init(content.Load <Texture2D>(enemy_icon));
                new_enemy.Visible     = false;
                new_enemy.destination = new Rectangle(
                    (int)((((float)graphics.Viewport.Width / 1366.0f) * 171.0f) + (((float)graphics.Viewport.Width / 1366.0f) * 31.0f * i)),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 664.0f),
                    (int)(((float)graphics.Viewport.Width / 1366.0f) * 31.0f),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 34.0f));
                m_enemy.Add(new_enemy);
                vis.AddEntity(new_enemy);
            }
        }
        public void LoadIcons(GraphicsDevice graphics, String bullet_icon, String enemy_icon, ContentManager content, Visualisation vis)
        {
            for (int i = 0; i < m_bullet_count; i++)
            {
                Graphics.Entity.Sprite new_bullet = new Graphics.Entity.Sprite();
                new_bullet.Init(content.Load<Texture2D>(bullet_icon));
                new_bullet.Visible = false;
                new_bullet.destination = new Rectangle(
                    (int)((((float)graphics.Viewport.Width / 1366.0f) * 175.0f) + (((float)graphics.Viewport.Width / 1366.0f) * 15.0f * i)),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 714.0f),
                    (int)(((float)graphics.Viewport.Width / 1366.0f) * 15.0f),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 47.0f));
                m_bullets.Add(new_bullet);
                vis.AddEntity(new_bullet);
            }

            m_enemy_count = Enemy_Container.enemies().Count;
            for (int i = 0; i < m_enemy_count; i++)
            {
                Graphics.Entity.Sprite new_enemy = new Graphics.Entity.Sprite();
                new_enemy.Init(content.Load<Texture2D>(enemy_icon));
                new_enemy.Visible = false;
                new_enemy.destination = new Rectangle(
                    (int)((((float)graphics.Viewport.Width / 1366.0f) * 171.0f) + (((float)graphics.Viewport.Width / 1366.0f) * 31.0f * i)),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 664.0f),
                    (int)(((float)graphics.Viewport.Width / 1366.0f) * 31.0f),
                    (int)(((float)graphics.Viewport.Height / 768.0f) * 34.0f));
                m_enemy.Add(new_enemy);
                vis.AddEntity(new_enemy);
            }
        }
        public void Init(ContentManager content, Visualisation vis, World world, GraphicsDevice graphics)
        {
            m_title_screen = new Graphics.Entity.Sprite();
            m_title_screen.Init(content.Load<Texture2D>("Menu"), graphics.Viewport.Bounds);
            vis.AddEntity(m_title_screen);

            m_menu_text = new Graphics.Entity.Text[3];

            for (int i = 0; i < 3; i++)
            {
                m_menu_text[i] = new Graphics.Entity.Text();
                m_menu_text[i].Init(content.Load<SpriteFont>("InGameFont"));
                vis.AddEntity(m_menu_text[i]);
            }

            m_menu_text[0].text = "Easy";
            m_menu_text[0].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 641.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 366.0f));

            m_menu_text[1].text = "Medium";
            m_menu_text[1].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 619.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 430.0f));

            m_menu_text[2].text = "Hard";
            m_menu_text[2].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 637.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 490.0f));

            int height = (int)m_menu_text[2].font.MeasureString("Hard").Y;
            m_cursor = new Graphics.Entity.Sprite();
            m_cursor.Init(content.Load<Texture2D>("cursor"), new Rectangle( 0, 0, height, height ) );
            vis.AddEntity(m_cursor);
        }
        public Player(Graphics.Entity.Sprite hud, Graphics.Entity.Text debug_text, SoundEffect gun_fire)
        {
            m_sprite     = hud;
            m_position   = Vector2.Zero;
            m_scale      = Vector2.One;
            m_rotation   = 0.0f;
            m_debug_text = debug_text;

            Camera.position = GamePlay.spawn_point;
            m_gun_fire      = gun_fire;
        }
        public void Init(ContentManager content, Visualisation vis, World world, GraphicsDevice graphics)
        {
            m_title_screen = new Graphics.Entity.Sprite();
            m_title_screen.Init(content.Load <Texture2D>("Menu"), graphics.Viewport.Bounds);
            vis.AddEntity(m_title_screen);

            m_menu_text = new Graphics.Entity.Text[3];

            for (int i = 0; i < 3; i++)
            {
                m_menu_text[i] = new Graphics.Entity.Text();
                m_menu_text[i].Init(content.Load <SpriteFont>("InGameFont"));
                vis.AddEntity(m_menu_text[i]);
            }


            m_menu_text[0].text     = "Easy";
            m_menu_text[0].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 641.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 366.0f));

            m_menu_text[1].text     = "Medium";
            m_menu_text[1].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 619.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 430.0f));

            m_menu_text[2].text     = "Hard";
            m_menu_text[2].position = new Vector2(
                (((float)graphics.Viewport.Width / 1366.0f) * 637.0f),
                (((float)graphics.Viewport.Height / 768.0f) * 490.0f));

            int height = (int)m_menu_text[2].font.MeasureString("Hard").Y;

            m_cursor = new Graphics.Entity.Sprite();
            m_cursor.Init(content.Load <Texture2D>("cursor"), new Rectangle(0, 0, height, height));
            vis.AddEntity(m_cursor);
        }
        protected override void LoadContent()
        {
            m_song = Content.Load<Song>("FightForFreedoms");

            DebugHelp.Draw_BoundingBox.Init(Content.Load<Effect>("lines"), GraphicsDevice);

            m_vis.Init(GraphicsDevice);

            Enemy_Container.Init(m_world, Content);

            Graphics.Entity.Text debug_text = new Graphics.Entity.Text();
            debug_text.Init(Content.Load<SpriteFont>("default_font"));

            Graphics.Entity.Sprite hud = new Graphics.Entity.Sprite();
            hud.Init(Content.Load<Texture2D>("scope-hd"), GraphicsDevice.Viewport.Bounds);
            hud.Visible = false;
            m_player = new Player(hud, debug_text, Content.Load<SoundEffect>("Fire"));
            m_world.AddEntity(m_player);
            m_player.LoadIcons(GraphicsDevice, "Bullet-Icon", "Enemy-Icon", Content, m_vis);

            List<Entity_Explosion> explosions_list = new List<Entity_Explosion>();

            for (int i = 0; i < 4; i++)
            {
                Graphics.Entity.Billboard explosion_model = new Graphics.Entity.Billboard();
                explosion_model.Init(Content.Load<Model>("Explosion"),
                                    Content.Load<Effect>("EffectBillboard"),
                                    Content.Load<Texture2D>("explosion_texture"));
                Entity_Explosion explosion = new Entity_Explosion(explosion_model);
                m_world.AddEntity(explosion);
                explosions_list.Add(explosion);
            }

            List<SoundEffect> explosion_sound = new List<SoundEffect>();

            for (int i = 0; i < 3; i++)
            {
                SoundEffect new_explosion_sound = Content.Load<SoundEffect>("explode_" + (i+1));
                explosion_sound.Add(new_explosion_sound);
            }

            BasicEffect city_effect = new BasicEffect(GraphicsDevice);
            city_effect.FogEnabled = true;
            city_effect.FogColor = new Vector3(0.6f, 0.6f, 0.6f);
            city_effect.FogStart = 0.0f;
            city_effect.FogEnd = 2000.0f;
            city_effect.SpecularPower = 10000000.0f;

            Graphics.Entity.Model city = new Graphics.Entity.Model();
            city.Init(Content.Load<Model>("city/city"));
            city.basiceffect = city_effect;
            m_city = new Entity_City(city, explosions_list, explosion_sound);
            m_world.AddEntity(m_city);

            Graphics.Entity.SkyBox skybox = new Graphics.Entity.SkyBox();
            skybox.Init(Content.Load<Model>("skybox/skysphere"),
                        Content.Load<Effect>("skybox/skybox_fx"),
                        Content.Load<TextureCube>("skybox/skytexture"));
            m_skybox = new Entity_SkyBox(skybox);
            m_world.AddEntity(m_skybox);

            //Menu

            m_menu.Init(Content, m_vis, m_world, GraphicsDevice);

            //Fonts

            m_ingame_text = new Graphics.Entity.Text();
            m_ingame_text.Init(Content.Load<SpriteFont>("InGameFont"));
            m_ingame_text.text = "Shoot All The Terrorists Before They Set The Bombs Off...";
            m_ingame_text.Visible = false;
            m_ingame_text.position = new Vector2((GraphicsDevice.Viewport.Width * 0.5f) -
                m_ingame_text.font.MeasureString(m_ingame_text.text).X * 0.5f,
                0.0f);
            m_vis.AddEntity(m_ingame_text);

            m_clock_text = new Graphics.Entity.Text();
            m_clock_text.Init(Content.Load<SpriteFont>("InGameFont"), "00:00:60");
            m_clock_text.Visible = false;
            m_clock_text.position = new Vector2(
                (((float)GraphicsDevice.Viewport.Width / 1366.0f) * 1024.0f),
                (((float)GraphicsDevice.Viewport.Height / 768.0f) * 690.0f) );
            m_vis.AddEntity(m_clock_text);

            m_clock_tick = Content.Load<SoundEffect>("clockTick");

            m_black_screen = new Graphics.Entity.Sprite();
            m_black_screen.Init(Content.Load<Texture2D>("blackPixel"),
                new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height) );
            m_black_screen.Visible = false;
            m_vis.AddEntity(m_black_screen);

            //play audio
            MediaPlayer.Volume = 0.5f;
            MediaPlayer.Play(m_song);
            MediaPlayer.IsRepeating = true;

            #if DEBUG
            m_vis.AddEntity(debug_text);
            #endif
        }
 public void AddEntity(Graphics.Entity.Sprite entity)
 {
     m_sprite.Add(entity);
 }
Exemple #8
0
        protected override void LoadContent()
        {
            m_song = Content.Load <Song>("FightForFreedoms");

            DebugHelp.Draw_BoundingBox.Init(Content.Load <Effect>("lines"), GraphicsDevice);

            m_vis.Init(GraphicsDevice);

            Enemy_Container.Init(m_world, Content);

            Graphics.Entity.Text debug_text = new Graphics.Entity.Text();
            debug_text.Init(Content.Load <SpriteFont>("default_font"));

            Graphics.Entity.Sprite hud = new Graphics.Entity.Sprite();
            hud.Init(Content.Load <Texture2D>("scope-hd"), GraphicsDevice.Viewport.Bounds);
            hud.Visible = false;
            m_player    = new Player(hud, debug_text, Content.Load <SoundEffect>("Fire"));
            m_world.AddEntity(m_player);
            m_player.LoadIcons(GraphicsDevice, "Bullet-Icon", "Enemy-Icon", Content, m_vis);

            List <Entity_Explosion> explosions_list = new List <Entity_Explosion>();

            for (int i = 0; i < 4; i++)
            {
                Graphics.Entity.Billboard explosion_model = new Graphics.Entity.Billboard();
                explosion_model.Init(Content.Load <Model>("Explosion"),
                                     Content.Load <Effect>("EffectBillboard"),
                                     Content.Load <Texture2D>("explosion_texture"));
                Entity_Explosion explosion = new Entity_Explosion(explosion_model);
                m_world.AddEntity(explosion);
                explosions_list.Add(explosion);
            }

            List <SoundEffect> explosion_sound = new List <SoundEffect>();

            for (int i = 0; i < 3; i++)
            {
                SoundEffect new_explosion_sound = Content.Load <SoundEffect>("explode_" + (i + 1));
                explosion_sound.Add(new_explosion_sound);
            }

            BasicEffect city_effect = new BasicEffect(GraphicsDevice);

            city_effect.FogEnabled    = true;
            city_effect.FogColor      = new Vector3(0.6f, 0.6f, 0.6f);
            city_effect.FogStart      = 0.0f;
            city_effect.FogEnd        = 2000.0f;
            city_effect.SpecularPower = 10000000.0f;

            Graphics.Entity.Model city = new Graphics.Entity.Model();
            city.Init(Content.Load <Model>("city/city"));
            city.basiceffect = city_effect;
            m_city           = new Entity_City(city, explosions_list, explosion_sound);
            m_world.AddEntity(m_city);

            Graphics.Entity.SkyBox skybox = new Graphics.Entity.SkyBox();
            skybox.Init(Content.Load <Model>("skybox/skysphere"),
                        Content.Load <Effect>("skybox/skybox_fx"),
                        Content.Load <TextureCube>("skybox/skytexture"));
            m_skybox = new Entity_SkyBox(skybox);
            m_world.AddEntity(m_skybox);

            //Menu

            m_menu.Init(Content, m_vis, m_world, GraphicsDevice);

            //Fonts

            m_ingame_text = new Graphics.Entity.Text();
            m_ingame_text.Init(Content.Load <SpriteFont>("InGameFont"));
            m_ingame_text.text     = "Shoot All The Terrorists Before They Set The Bombs Off...";
            m_ingame_text.Visible  = false;
            m_ingame_text.position = new Vector2((GraphicsDevice.Viewport.Width * 0.5f) -
                                                 m_ingame_text.font.MeasureString(m_ingame_text.text).X * 0.5f,
                                                 0.0f);
            m_vis.AddEntity(m_ingame_text);

            m_clock_text = new Graphics.Entity.Text();
            m_clock_text.Init(Content.Load <SpriteFont>("InGameFont"), "00:00:60");
            m_clock_text.Visible  = false;
            m_clock_text.position = new Vector2(
                (((float)GraphicsDevice.Viewport.Width / 1366.0f) * 1024.0f),
                (((float)GraphicsDevice.Viewport.Height / 768.0f) * 690.0f));
            m_vis.AddEntity(m_clock_text);

            m_clock_tick = Content.Load <SoundEffect>("clockTick");

            m_black_screen = new Graphics.Entity.Sprite();
            m_black_screen.Init(Content.Load <Texture2D>("blackPixel"),
                                new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
            m_black_screen.Visible = false;
            m_vis.AddEntity(m_black_screen);

            //play audio
            MediaPlayer.Volume = 0.5f;
            MediaPlayer.Play(m_song);
            MediaPlayer.IsRepeating = true;

#if DEBUG
            m_vis.AddEntity(debug_text);
#endif
        }