Exemple #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
     mapRendere = new TiledMapRenderer(GraphicsDevice);
     cam        = new Camera2D(GraphicsDevice);
     base.Initialize();
 }
        /// <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);

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

            SetUpTiles();
            LoadObjects();

            player.Load(Content, this);

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

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

            camera          = new Camera2D(viewportAdapter);
            camera.Position = new Vector2(0, graphics.GraphicsDevice.Viewport.Height);


            gameMusic = Content.Load <Song>("Foreboding");
            MediaPlayer.Play(gameMusic);
        }
Exemple #3
0
        public Map(string Path, Hero hero)
        {
            Global.penumbra.Hulls.Clear();
            Global.penumbra.Lights.Clear();
            // Map
            path             = Path;
            map              = Global.content.Load <TiledMap>(path);
            mapRenderer      = new TiledMapRenderer(Global.graphicsDevice);
            Global.collision = new Collision();
            Global.collision.LoadMap("../../Content/" + path + ".tmx");
            // Spawner
            spawnPoints.Add(new SpawnPoint("Autre/vide", new Vector2(500, 500), new Vector2(60, 60)));

            Global.penumbra.Lights.Add(heroLight);
            foreach (KeyValuePair <Vector2, Color> obj in Global.collision.mapLight)
            {
                Light mapLight = new TexturedLight(lightTex)
                {
                    Scale     = new Vector2(50),
                    Color     = obj.Value,
                    Intensity = 1.2f,
                    Position  = new Vector2(obj.Key.X - 16, -obj.Key.Y + 30),
                    Rotation  = MathHelper.PiOver2
                };
                mapLights.Add(mapLight);
                Global.penumbra.Lights.Add(mapLight);
            }
        }
 public MapComponent(GraphicsDevice graphicsDevice, Game game, Camera2D camera)
 {
     _graphicsDevice = graphicsDevice;
     _game           = game;
     _camera         = camera;
     _mapRenderer    = new TiledMapRenderer(graphicsDevice);
 }
Exemple #5
0
 public override void OnAddedToEntity()
 {
     _tiledMapRenderer      = Entity.Scene.FindEntity("tiled-map").GetComponent <TiledMapRenderer>();
     _swordCollisionHandler = new SwordCollisionHandler(_tiledMapRenderer);
     this.SetHeight(16);
     this.SetWidth(2);
 }
Exemple #6
0
        public void Initialize(ContentManager Content)
        {
            BulletTexture = Content.Load <Texture2D>("Sprites/Bullet");

            CursorInfo = new CursorInfo(MouseCursor.FromTexture2D(Content.Load <Texture2D>("Sprites/CrossHair"), 0, 0), true);

            //Initialize map and camera
            mapRenderer = new TiledMapRenderer();
            camera      = new Camera(ScreenManager.GraphicsDevice);
            hubMap      = Map.LoadTiledMap(ScreenManager.GraphicsDevice, "Content/maps/hub.tmx");
            ScreenManager.Game.IsMouseVisible = false;

            //Create the player
            player = new Player(Content.Load <Texture2D>("Sprites/Player"), new Vector2(456, 456), hubMap, Content, ScreenManager);

            //Initialize some systems
            ParticleSystem.Instance.Initialize(Content);
            EntityManager.Instance.Initialize(player.playerController);
            hubMap.LoadObjects(ScreenManager);

            //Add new entities
            EntityManager.Instance.AddEntity(player);

            //Create player interface
            playerInterface = new PlayerInterface(player, Content, ScreenManager.GraphicsDevice);
            player.playerController.OnControlChanged += playerInterface.ChangeInterface;
        }
Exemple #7
0
        protected override void Initialize()
        {
            //create a new tiled map rendered
            tiledMapRenderer = new TiledMapRenderer(graphics.GraphicsDevice);

            base.Initialize();
        }
Exemple #8
0
        public void LoadContent(ContentManager content)
        {
            // TODO: fazer carregar o Level2, chamar o Luiz
            map         = content.Load <TiledMap>("Map1");
            mapRenderer = new TiledMapRenderer(graphics.GraphicsDevice, map);

            var objectsLayer = map.GetLayer <TiledMapObjectLayer>("Object Layer 1");
            var wallLayer    = map.GetLayer <TiledMapTileLayer>("Wall Layer");

            foreach (var i in objectsLayer.Objects)
            {
                if (i.Type == "Yoda")
                {
                    Player yoda = new Player(i);
                    entities.Add(yoda);
                }

                if (i.Type == "Enemy1")
                {
                    Enemy1 enemy1 = new Enemy1(i);
                    entities.Add(enemy1);
                }
            }

            foreach (var i in wallLayer.Tiles)
            {
                wallTiles.Add(i);
            }

            entities.ForEach(entity => { entity.Load(content); });
        }
        public override void LoadContent()
        {
            base.LoadContent();

            var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);

            _camera = new Camera2D(viewportAdapter);

            _map         = Content.Load <TiledMap>("level-1");
            _mapRenderer = new TiledMapRenderer(GraphicsDevice);

            _entityComponentSystem = new EntityComponentSystem();
            _entityFactory         = new EntityFactory(_entityComponentSystem, Content);

            var service    = new TiledObjectToEntityService(_entityFactory);
            var spawnPoint = _map.GetLayer <TiledMapObjectLayer>("entities").Objects.Single(i => i.Type == "Spawn").Position;

            _entityComponentSystem.RegisterSystem(new PlayerMovementSystem());
            _entityComponentSystem.RegisterSystem(new EnemyMovementSystem());
            _entityComponentSystem.RegisterSystem(new CharacterStateSystem(_entityFactory, spawnPoint));
            _entityComponentSystem.RegisterSystem(new BasicCollisionSystem(gravity: new Vector2(0, 1150)));
            _entityComponentSystem.RegisterSystem(new ParticleEmitterSystem());
            _entityComponentSystem.RegisterSystem(new AnimatedSpriteSystem());
            _entityComponentSystem.RegisterSystem(new SpriteBatchSystem(GraphicsDevice, _camera)
            {
                SamplerState = SamplerState.PointClamp
            });

            service.CreateEntities(_map.GetLayer <TiledMapObjectLayer>("entities").Objects);
        }
Exemple #10
0
        protected override void Initialize()
        {
            mapRenderer = new TiledMapRenderer(GraphicsDevice);
            cam         = new Camera2D(GraphicsDevice);

            base.Initialize();
        }
Exemple #11
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);
            arialFont = Content.Load <SpriteFont>("Arial");
            heart     = Content.Load <Texture2D>("heart");

            var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, viewWidth, viewHeight);

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

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

            gameoverSound = Content.Load <Song>("GameOver");
            winSound      = Content.Load <Song>("Win");

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

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

            // TODO: use this.Content to load your game content here
        }
Exemple #12
0
        public void SetupTiles()
        {
            if (Core.Scene == null)
            {
                return;
            }
            MapList = FileManager.GetMapInformation("Data/" + ConstantValues.MapDataFileName);
            Map.Map         map = null;
            CharacterPlayer c   = LoginManagerClient.GetCharacter();

            foreach (var maps in MapList)
            {
                if (maps.MapName == c.LastMultiLocation)
                {
                    map = maps;
                }
            }
            if (map != null)
            {
                entity = Scene.CreateEntity(map.MapName);
                TiledMapRenderer tmr = entity.AddComponent(new TiledMapRenderer(map.TmxMap));
                tmr.Material = new Material(BlendState.NonPremultiplied);
                tmr.SetRenderLayer(1);
                tmr.SetLayersToRender(new string[] { "Tile", "Collision", "Decoration", "CustomCollision" });
                TmxObjectGroup l = map.TmxMap.GetLayer <TmxObjectGroup>("Objects");
                foreach (TmxObject obj in l.Objects)
                {
                    ObjectSceneEntity osc = new ObjectSceneEntity(obj, tmr.TiledMap.TileWidth);
                    osc.SetPosition(osc.Position);
                    Scene.AddEntity(osc);
                }
            }
        }
Exemple #13
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (!init)
            {
                TmxRenderer = new TiledMapRenderer(Game.GraphicsDevice);
                LoadMaps("content/maps");

                Set("town1");
                init = true;
            }

            /*PositionComponent position = Player.GetComponent<PositionComponent>();
             * if (position.TileY < 0)
             * {
             *  Move(Direction.Up);
             * }
             * if (position.TileX < 0)
             * {
             *  Move(Direction.Left);
             * }
             * if (position.TileY >= CurrentMap.MapHeight)
             * {
             *  Move(Direction.Down);
             * }
             * if (position.TileX >= CurrentMap.MapWidth)
             * {
             *  Move(Direction.Right);
             * }*/
        }
        /// <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, this);               // Call the "Load" function in the Player class

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

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

            camera          = new Camera2D(viewportAdapter);
            camera.Position = new Vector2(0, graphics.GraphicsDevice.Viewport.Height);

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

            // Load the game music
            gameMusic = Content.Load <Song>("SuperHero_original_no_Intro");
            MediaPlayer.Play(gameMusic);

            SetUpTiles();
            LoadObjects();
        }
Exemple #15
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);
            map           = Content.Load <TiledMap>("test1");
            mapWidth      = map.Width;
            mapHeight     = map.Height;
            tileWidth     = map.TileWidth;
            collisionGrid = new int[mapHeight, mapWidth];
            var tileLayer = map.GetLayer <TiledMapTileLayer>("Tile Layer 1");

            for (int i = 0; i < mapHeight; i++)
            {
                for (int j = 0; j < mapWidth; j++)
                {
                    System.Diagnostics.Debug.Write((int)Char.GetNumericValue(tileLayer.GetTile((ushort)j, (ushort)i).ToString()[18]) + " ,");
                    collisionGrid[i, j] = (int)Char.GetNumericValue(tileLayer.GetTile((ushort)j, (ushort)i).ToString()[18]);
                }
                System.Diagnostics.Debug.WriteLine("");
            }
            //foreach (int i in collisionGrid)
            //{
            //    System.Diagnostics.Debug.Write("{0} ", i.ToString());
            //}
            collisionMap = new CollisionMap(collisionGrid, map.TileHeight);
            mapRenderer  = new TiledMapRenderer(GraphicsDevice, map);
            // TODO: use this.Content to load your game content here
            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, 0);

            player.Initialize(Content.Load <Texture2D>("Graphics\\basicchar"), playerPosition, 0);
            camera.Pos = new Vector2(playerPosition.X, playerPosition.Y);
        }
Exemple #16
0
        public override void LoadContent()
        {
            base.LoadContent();
            PresentationParameters pp = GraphicsDevice.PresentationParameters;

            lightsRenderTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight);
            mainRenderTarget   = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight);
            lightMask          = Content.Load <Texture2D>("lightmask");
            lightEffect        = Content.Load <Effect>("lighteffect");

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

            collisionComponent = new CollisionComponent(new RectangleF(-10000, -5000, 20000, 10000));

            var nonBlankTiles = map.TileLayers.FirstOrDefault()?.Tiles.Where(tile => !tile.IsBlank);

            if (nonBlankTiles != null)
            {
                foreach (var mapTile in nonBlankTiles)
                {
                    var stationaryCollisionObject =
                        new StationaryCollisionObject(new Vector2((mapTile.X + 1) * map.TileWidth, (mapTile.Y + 1) * map.TileWidth));
                    collisionComponent.Insert(stationaryCollisionObject);
                    StationaryCollisionObjects.Add(stationaryCollisionObject);
                }
            }


            SpawnPlayers();
        }
Exemple #17
0
        /*if player exited room, change current room and set player position to the correct entrance of the new room*/
        protected void changeRoom(string doorEntered)
        {
            currentRoom = _level.rooms[(int)currentRoomPos.X, (int)currentRoomPos.Y];
            switch (doorEntered)
            {
            case "right":
                _player._position.X = 15;
                break;

            case "left":
                _player._position.X = ScreenWidth - 100;
                break;

            case "top":
                _player._position.Y = ScreenHeight - 100;
                break;

            case "bottom":
                _player._position.Y = 15;
                break;
            }

            /*Tileset local identity = tilemap global identity - 1*/
            mapRenderer = new TiledMapRenderer(GraphicsDevice, currentRoom.map);
            if (!currentRoom.cleared)
            {
                CreateEnemies();
            }

            checkDoors();
            //setTiles();
        }
Exemple #18
0
 public override void OnAddedToEntity()
 {
     _sprite           = this.GetComponent <SpriteRenderer>();
     _tiledMapRenderer = Entity.Scene.FindEntity("tiled-map").GetComponent <TiledMapRenderer>();
     _mover            = new Mover();
     Entity.AddComponent(_mover);
 }
Exemple #19
0
        private void GenerateTileMap()
        {
            _tiledMap         = _game.Content.Load <TiledMap>("Test");
            _tiledMapRenderer = new TiledMapRenderer(_game.GraphicsDevice, _tiledMap);

            _mapWidth  = _tiledMap.WidthInPixels;
            _mapHeight = _tiledMap.HeightInPixels;

            _collisionComponent = new CollisionComponent(new RectangleF(0, 0, _mapWidth, _mapHeight));

            TiledMapTileLayer collidables = _tiledMap.GetLayer <TiledMapTileLayer>("Collidable");

            if (collidables != null)
            {
                foreach (TiledMapTile t in collidables.Tiles)
                {
                    // Global Identifier 0 means tile is empty
                    if (t.GlobalIdentifier == 0)
                    {
                        continue;
                    }

                    Vector2 pos = Vector2.Zero;

                    pos.X = t.X * collidables.TileWidth;
                    pos.Y = t.Y * collidables.TileHeight;

                    Size2 size = new Size2(collidables.TileWidth, collidables.TileHeight);

                    Wall w = new Wall(pos, size);
                    _collisionComponent.Insert(w);
                }
            }
        }
Exemple #20
0
        private TiledMapRenderer createRenderer(int entity, MapComponent mapComponent)
        {
            TiledMap         map      = mapComponent.Map;
            TiledMapRenderer renderer = new TiledMapRenderer(_graphics, map);

            _renderers.Add(entity, renderer);
            return(renderer);
        }
Exemple #21
0
        public Renderers(GraphicsDevice gD)
        {
            // Store the graphics device.
            _gD = gD;

            // Create new TiledMapRenderer.
            _mapRenderer = new TiledMapRenderer(gD);
        }
Exemple #22
0
 public Overworld(TiledMap newMap, GraphicsDevice graphics)
 {
     layer       = 0;
     visible     = true;
     map         = newMap;
     mapRenderer = new TiledMapRenderer(graphics, map);
     camera      = new OrthographicCamera(graphics);
 }
 protected override void Initialize()
 {
     mapRenderer = new TiledMapRenderer(GraphicsDevice);
     cam         = new Camera2D(GraphicsDevice);
     //graphics.IsFullScreen = true;
     //graphics.ApplyChanges();
     base.Initialize();
 }
Exemple #24
0
        public Map(GraphicsDevice pDevice, ContentManager content, int pTileWidth, int pTileHeight, int pWidth, int pHeight)
        {
            ConvertUnits.SetDisplayUnitToSimUnitRatio(100);
            entityList = new List<MapEntity>();
            verticesList = new List<Vector2>();
            //light = content.Load<Texture2D>("lightmask");
            effect = content.Load<Effect>("File");
            //effect.Parameters["lightMask"].SetValue(light);
            prevState = Keyboard.GetState();
            hud = new Hud(new string[] { "Undertale is bad,\nand so am I." }, content);
            speaking = false;
            blocks = new List<Body>();
            tileWidth = pTileWidth;
            tileHeight = pTileHeight;
            width = pWidth;
            height = pHeight;
            g = pDevice;
            cont = content;

            menu = new Menu(content, null);

            camera = new Camera2D(pDevice);
            debug = content.Load<Texture2D>("overworld_gutter");

            tMap = content.Load<TiledMap>("Map/Tazmily/Tazmily");
            mapRenderer = new TiledMapRenderer(pDevice);

            world = new World(Vector2.Zero);
            //world.ContactManager.OnBroadphaseCollision += BroadphaseHandler;
            //world.ContactManager.EndContact += EndContactHandler;
            debugView = new DebugViewXNA(world);
            debugView.LoadContent(pDevice, content);
            //debugView.AppendFlags(DebugViewFlags.DebugPanel);
            //debugView.AppendFlags(DebugViewFlags.PolygonPoints);
            //debugView.AppendFlags(DebugViewFlags.ContactPoints);
            //debugView.AppendFlags(DebugViewFlags.AABB);
            debugView.AppendFlags(DebugViewFlags.Shape);
            debugView.DefaultShapeColor = Color.Green;

            //camera.Position = player.body.Position;
            //Console.WriteLine("Scunt: " + tMap.ObjectLayers.Count);
            player = new Player(world, content, 16, 23);
            //npc = new NPC(world, content, colArray, 2, false, 16, 14, new string[] {"Weebs are worse\nthan fortnite\ngamers.", "Where's the lie?" });

            //Body b1 = BodyFactory.CreateRectangle(world, 3, 3, 1);

            blockDims = new List<Vector2>();
            MakeCollisionBodies();

            npcs = new NPC[] {
                //new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@You wanna see the special?\n@It's a detective story. Some kind of <Columbo>\n  knock-off.\n@Well, ya interested or not?", "@Get outta here." }),
                new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@Your name Steve Foley? Of course it is.\n  You are great. Fantastic.\n@Good job Steve.", "@Get outta here." }),
                //new NewNPC(world, content, player, 0, true, 18, 18, new string[] {"help"}, 4, 1)
            };
            entityList.Add(player);
            foreach (NPC n in npcs)
                entityList.Add(n);
        }
Exemple #25
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
            counter     = new FrameCounter();
            camera      = new Camera2D(new WindowViewportAdapter(Window, GraphicsDevice));
            mapRenderer = new TiledMapRenderer(GraphicsDevice);

            base.Initialize();
        }
Exemple #26
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()
        {
            base.Initialize();

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

            camera = new Camera2D(new WindowViewportAdapter(Window, GraphicsDevice));
        }
Exemple #27
0
        public void ChangeMap(Map.Map newMap)
        {
            entity.RemoveComponent <TiledMapRenderer>();
            TiledMapRenderer tmr = entity.AddComponent(new TiledMapRenderer(newMap.TmxMap));

            tmr.Material = new Material(BlendState.NonPremultiplied);
            tmr.SetRenderLayer(1);
            tmr.SetLayersToRender(new string[] { "Tile", "Collision", "Decoration", "CustomCollision" });
        }
 protected override void LoadContent()
 {
     _spriteBatch  = new SpriteBatch(GraphicsDevice);
     player.sprite = Content.Load <Texture2D>("Textures/Player");
     camPos        = new Vector2(100, 100);
     cam.LookAt(camPos);
     map         = Content.Load <TiledMap>("map");
     mapRenderer = new TiledMapRenderer(GraphicsDevice, map);
 }
Exemple #29
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
     viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, screenWidth * 2, screenHeight * 2);
     mapRenderer     = new TiledMapRenderer(GraphicsDevice);
     camera          = new Camera2D(viewportAdapter);
     position        = new Vector2(1200, 900);
     base.Initialize();
 }
Exemple #30
0
        private TiledMap LoadNextMap()
        {
            var name = _availableMaps.Dequeue();

            _map = Content.Load <TiledMap>($"TiledMaps/{name}");
            _availableMaps.Enqueue(name);
            _mapRenderer = new TiledMapRenderer(GraphicsDevice, _map);
            return(_map);
        }