Esempio n. 1
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);

            // TODO: use this.Content to load your game content here
            player.Load(Content);
            enemy.Load(Content);

            var ViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, ScreenWidth, ScreenHeight);

            Camera          = new Camera2D(ViewportAdapter);
            Camera.Position = new Vector2(0, ScreenHeight);

            Map = Content.Load <TiledMap>("Level1");
            foreach (TiledTileLayer Layer in Map.TileLayers)
            {
                if (Layer.Name == "Collisions")
                {
                    CollisionLayer = Layer;
                }
            }
            Arialfont = Content.Load <SpriteFont>("Arial");
            Heart     = Content.Load <Texture2D>("Heart");

            AIE.StateManager.CreateState("Splash", new SplashState());
            AIE.StateManager.CreateState("Game", new GameState());
            AIE.StateManager.CreateState("GamerOver", new GameOverState());

            AIE.StateManager.PushState("Splash");

            foreach (TiledObjectGroup Group in Map.ObjectGroups)
            {
                if (Group.Name == "Enemies")
                {
                    foreach (TiledObject Obj in Group.Objects)
                    {
                        Enemy enemy = new Enemy(this);
                        enemy.Load(Content);
                        enemy.Position = new Vector2(Obj.X, Obj.Y);
                        Enemies.Add(enemy);
                    }
                }
                if (Group.Name == "Goal")
                {
                    TiledObject Obj = Group.Objects[0];
                    if (Obj != null)
                    {
                        AnimatedTexture Anim = new AnimatedTexture(Vector2.Zero, 0, 1, 1);

                        Anim.Load(Content, "Goal", 1, 1);
                        Goal = new Sprite();
                        Goal.Add(Anim, 0, 5);
                        Goal.position = new Vector2(Obj.X, Obj.Y);
                    }
                }
            }
            GameMusic = Content.Load <Song>("SuperHero_original_no_Intro");
            MediaPlayer.Play(GameMusic);
        }
Esempio n. 2
0
 private void Start()
 {
     player.SetPosition(new Vector2(64, 448));
     score = 0;
     enemies.Clear();
     foreach (TiledMapObjectLayer layer in map.ObjectLayers)
     {
         if (layer.Name == "Enemies")
         {
             foreach (TiledMapObject obj in layer.Objects)
             {
                 Enemy enemy = new Enemy(this);
                 enemy.Load(Content);
                 enemy.Position = new Vector2(
                     obj.Position.X, obj.Position.Y);
                 enemies.Add(enemy);
             }
         }
         if (layer.Name == "Goal")
         {
             TiledMapObject obj = layer.Objects[0];
             if (obj != null)
             {
                 AnimatedTexture anim = new AnimatedTexture(
                     Vector2.Zero, 0, 1, 1);
                 anim.Load(Content, "goal", 1, 1);
                 goal = new Sprite();
                 goal.Add(anim, 0, -32);
                 goal.position = new Vector2(
                     obj.Position.X, obj.Position.Y);
             }
         }
     }
 }
Esempio n. 3
0
        // loads one enemy
        private void LoadEnemy(int x, int y)
        {
            Enemy enemy = new Enemy(this);

            enemy.Load(Content);
            enemy.Position = new Vector2(x, y);
            enemies.Add(enemy);
        }
Esempio n. 4
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);

            // TODO: use this.Content to load your game content here
            player.Load(Content);

            arialFont = Content.Load <SpriteFont>("Arial");
            heart     = Content.Load <Texture2D>("heart");


            var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice,
                                                            (int)(graphics.GraphicsDevice.Viewport.Width), (int)(graphics.GraphicsDevice.Viewport.Height));

            camera          = new Camera2D(viewportAdapter);
            camera.Position = player.Position - new Vector2(ScreenWidth, ScreenHeight);

            map = Content.Load <TiledMap>("Level1");
            foreach (TiledTileLayer layer in map.TileLayers)
            {
                if (layer.Name == "Collisions")
                {
                    collisionLayer = layer;
                }
            }

            foreach (TiledObjectGroup group in map.ObjectGroups)
            {
                if (group.Name == "enemies")
                {
                    foreach (TiledObject obj in group.Objects)
                    {
                        Enemy enemy = new Enemy(this);
                        enemy.Load(Content);
                        enemy.Position = new Vector2(obj.X, obj.Y);
                        enemies.Add(enemy);
                    }
                }
                if (group.Name == "goal")
                {
                    TiledObject obj = group.Objects[0];
                    if (obj != null)
                    {
                        AnimatedTexture anim = new AnimatedTexture(
                            Vector2.Zero, 0, 1, 1);
                        anim.Load(Content, "chest", 1, 1);
                        goal = new Sprite();
                        goal.Add(anim, 0, 5);
                        goal.position = new Vector2(obj.X, obj.Y);
                    }
                }
            }

            gameMusic = Content.Load <Song>("Superhero_Violin");
            MediaPlayer.Play(gameMusic);
        }
Esempio n. 5
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);

            player.Load(Content);

            var ViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, ScreenWidth, ScreenHeight);

            camera          = new Camera2D(ViewportAdapter);
            camera.Position = new Vector2(0, ScreenHeight);
            map             = Content.Load <TiledMap>("Level1");

            foreach (TiledTileLayer layer in map.TileLayers)
            {
                if (layer.Name == "Collisions")
                {
                    collisionLayer = layer;
                }

                gameMusic = Content.Load <Song>("SuperHero_original_no_Intro");
                MediaPlayer.Play(gameMusic);
            }

            foreach (TiledObjectGroup group in map.ObjectGroups)
            {
                if (group.Name == "Enemies")
                {
                    foreach (TiledObject obj in group.Objects)
                    {
                        Enemy enemy = new Enemy(this);
                        enemy.Load(Content);
                        enemy.Position = new Vector2(obj.X, obj.Y);
                        enemies.Add(enemy);
                    }
                }
                Debug.WriteLine(group.Name);
                if (group.Name == "Goal")
                {
                    TiledObject obj = group.Objects[0];
                    if (obj != null)
                    {
                        AnimatedTexture anim = new AnimatedTexture(Vector2.Zero, 0, 1, 1);
                        anim.Load(Content, "chest", 1, 1);
                        goal = new Sprite();
                        goal.Add(anim, 0, 5);
                        goal.position = new Vector2(obj.X, obj.Y);
                    }
                }
                // TODO: use this.Content to load your game content here
            }
        }
Esempio n. 6
0
        private void Restart()
        {
            foreach (TiledTileLayer layer in map.TileLayers)
            {
                if (layer.Name == "Collisions")
                {
                    collisionLayer = layer;
                }

                gameMusic = Content.Load <Song>("SuperHero_original_no_Intro");
                MediaPlayer.Play(gameMusic);
            }

            foreach (TiledObjectGroup group in map.ObjectGroups)
            {
                if (group.Name == "Enemies")
                {
                    foreach (TiledObject obj in group.Objects)
                    {
                        Enemy enemy = new Enemy(this);
                        enemy.Load(Content);
                        enemy.Position = new Vector2(obj.X, obj.Y);
                        enemies.Add(enemy);
                    }
                }
                Debug.WriteLine(group.Name);
                if (group.Name == "Goal")
                {
                    TiledObject obj = group.Objects[0];
                    if (obj != null)
                    {
                        AnimatedTexture anim = new AnimatedTexture(Vector2.Zero, 0, 1, 1);
                        anim.Load(Content, "chest", 1, 1);
                        goal = new Sprite();
                        goal.Add(anim, 0, 5);
                        goal.position = new Vector2(obj.X, obj.Y);
                    }
                }
                // TODO: use this.Content to load your game content here
            }
        }
Esempio n. 7
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);

            player.Load(Content);
            candaraFont = Content.Load <SpriteFont>("Candara");
            heart       = Content.Load <Texture2D>("heart");

            BoxingViewportAdapter viewportAdapter = new BoxingViewportAdapter(Window,
                                                                              GraphicsDevice,
                                                                              ScreenWidth, ScreenHeight);

            camera          = new Camera2D(viewportAdapter);
            camera.Position = new Vector2(0, ScreenHeight);

            gameMusic          = Content.Load <Song>("Music/SuperHero_original_no_Intro");
            MediaPlayer.Volume = 0.1f;
            MediaPlayer.Play(gameMusic);

            map         = Content.Load <TiledMap>("samp1");
            mapRenderer = new TiledMapRenderer(GraphicsDevice);

            foreach (TiledMapTileLayer layer in map.TileLayers)
            {
                if (layer.Name == "Collisions")
                {
                    collisionLayer = layer;
                }
            }

            foreach (TiledMapObjectLayer layer in map.ObjectLayers)
            {
                if (layer.Name == "Enemies")
                {
                    foreach (TiledMapObject obj in layer.Objects)
                    {
                        Enemy enemy = new Enemy(this);
                        enemy.Load(Content);
                        enemy.Position = new Vector2(obj.Position.X, obj.Position.Y);
                        enemies.Add(enemy);
                    }
                }

                if (layer.Name == "Loot")
                {
                    TiledMapObject obj = layer.Objects[0];
                    if (obj != null)
                    {
                        AnimatedTexture anim = new AnimatedTexture(Vector2.Zero, 0, 1, 1);
                        anim.Load(Content, "gem_3", 1, 1);
                        gem = new Sprite();
                        gem.Add(anim, 0, 5);
                        gem.position = new Vector2(obj.Position.X, obj.Position.Y);
                    }
                }
            }


            // TODO: use this.Content to load your game content here
        }
        public override void Update(ContentManager Content, GameTime gameTime)
        {
            switch (level)
            {
            case Level.W1_L1:
                map = Content.Load <TiledMap>("Level_1");
                break;

            case Level.W1_L2:
                map = Content.Load <TiledMap>("Level_2");
                break;

            case Level.W1_L3:
                map = Content.Load <TiledMap>("Level_3");
                break;
            }

            if (isLoaded == false)
            {
                isLoaded    = true;
                ventureFont = Content.Load <SpriteFont>("3Dventure");
                psFont      = Content.Load <SpriteFont>("ps2p");
                //bgm = Content.Load<Song>("sacrifice");
                heart = Content.Load <Texture2D>("heart_x16");

                var viewportAdapter = new BoxingViewportAdapter(game.Window, game.GraphicsDevice, ScreenWidth, ScreenHeight);
                camera          = new Camera2D(viewportAdapter);
                camera.Position = new Vector2(0, ScreenHeight);

                foreach (TiledTileLayer layer in map.TileLayers)
                {
                    if (layer.Name == "collision")
                    {
                        collisionLayer = layer;
                    }
                }

                foreach (TiledObjectGroup group in map.ObjectGroups)
                {
                    if (group.Name == "player_spawn")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            player = new Player(this);
                            player.Load(Content);
                            player.Position = new Vector2(obj.X, obj.Y);
                        }
                    }

                    if (group.Name == "enemy_spawn")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            Enemy enemy = new Enemy(this);
                            enemy.Load(Content);
                            enemy.Position = new Vector2(obj.X, obj.Y);
                            enemies.Add(enemy);
                        }
                    }

                    if (group.Name == "goal")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            goal = new Goal(this);
                            goal.Load(Content);
                            goal.Position = new Vector2(obj.X, obj.Y);
                        }
                    }

                    if (group.Name == "key")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            key = new Key(this);
                            key.Load(Content);
                            key.Position = new Vector2(obj.X, obj.Y);
                        }
                    }

                    if (group.Name == "lock")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            LockedWall lockedWall = new LockedWall(this);
                            lockedWall.Load(Content);
                            lockedWall.Position = new Vector2(obj.X, obj.Y);
                            lockedWalls.Add(lockedWall);
                        }
                    }

                    if (group.Name == "extralife")
                    {
                        foreach (TiledObject obj in group.Objects)
                        {
                            extralife = new ExtraLife(this);
                            extralife.Load(Content);
                            extralife.Position = new Vector2(obj.X, obj.Y);
                        }
                    }
                }
            }

            if (musicLoad == false)
            {
                musicLoad = true;
                //MediaPlayer.Play(bgm);
            }

            keyS      = Content.Load <SoundEffect>("keys");
            splat     = Content.Load <SoundEffect>("splat");
            keyInst   = keyS.CreateInstance();
            splatInst = splat.CreateInstance();

            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            camera.Position = player.Position - new Vector2(ScreenWidth / 2, ScreenHeight / 1.5f);
            CameraMechanics();

            timer -= deltaTime;

            CheckCollisions();
            goal.Update(deltaTime);
            player.Update(deltaTime);
            key.Update(deltaTime);
            extralife.Update(deltaTime);
            foreach (Enemy e in enemies)
            {
                e.Update(deltaTime);
                e.ParticleUpdate(gameTime);
            }
            foreach (LockedWall lw in lockedWalls)
            {
                lw.Update(deltaTime);
            }

            if (game.AllowInput && game.AllowMenu == true)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    AIE.StateManager.PushState("PauseState");
                    game.ResetInputTimer();
                }
            }

            if (game.AllowMenu == false)
            {
                if (Keyboard.GetState().IsKeyUp(Keys.Enter))
                {
                    game.AllowMenu = true;
                }
            }
        }