Exemplo n.º 1
0
        public void LoadContent(ContentManager content)
        {
            _entityManager = new EntityManager();

            _map               = FileReadWriter.ReadFromBinary <Map>(MapDirectory);
            _tileset           = content.Load <Texture2D>(_map.TextureMap.TileTexture);
            _textureBackground = content.Load <Texture2D>("sprites/backgrounds/background1");
            _song              = content.Load <Song>("music/AVoid");
            MediaPlayer.Play(_song);
            MediaPlayer.IsRepeating = true;

            KeyboardInput.AddKey(Microsoft.Xna.Framework.Input.Keys.Space);


            int curPlat = 0;

            for (int x = 0; x < _map.Width; x++)
            {
                for (int y = 0; y < _map.Height; y++)
                {
                    if (_map.Tiles[x, y].ID != 8 &&
                        _map.Tiles[x, y].ID != 10 &&
                        _map.Tiles[x, y].ID != 11 &&
                        _map.Tiles[x, y].ID != 12 &&
                        _map.Tiles[x, y].ID != 13 &&
                        _map.Tiles[x, y].ID != 17 &&
                        _map.Tiles[x, y].ID != 18 &&
                        _map.Tiles[x, y].ID != 19)
                    {
                        //content.Load<Texture2D>(@"sprites/objects/warpBall")
                        _entityManager.AddEntity(new EntityPlatform("platform" + curPlat++, null, new Vector2(x * (_map.TextureMap.TileWidth) * 2.0f, y * (_map.TextureMap.TileHeight * 2.0f)) - _position, new Vector2((_map.TextureMap.TileWidth * 2.0f), (_map.TextureMap.TileHeight * 2.0f)), true));
                    }
                }
            }


            //_oldPlayerPos = _entityManager.GetEntity("player").GetComponent<ComponentTransform>().WorldTransform.Translate;

            _entityManager.AddEntity(new EntityProjectile("player",
                                                          content.Load <Texture2D>(@"sprites/player/char1"),
                                                          new Vector2(400.0f, 240.0f),
                                                          new Vector2(32.0f, 64.0f), true));

            _oldPlayerPos = _entityManager.GetEntity("player").GetComponent <ComponentTransform>().WorldTransform.Translate;


            _entityManager.AddEntity(new EntityProjectile("warpBall",
                                                          content.Load <Texture2D>(@"sprites/objects/warpBall"),
                                                          new Vector2(400.0f, 240.0f),
                                                          new Vector2(32.0f, 32.0f), true));
            //_entityManager.GetEntity("warpBall").GetComponent<ComponentTransform>().SetParent(_entityManager.GetEntity("player").GetComponent<ComponentTransform>());
            _entityManager.GetEntity("warpBall").GetComponent <ComponentTransform>().Scale = 0.6f;
            _entityManager.GetEntity("warpBall").GetComponent <ComponentCollision>().SetSize(32.0f * 0.6f, 32.0f * 0.6f);
            _entityManager.GetEntity("warpBall").GetComponent <ComponentPhysics>().DragX = 0.9999f;
        }
Exemplo n.º 2
0
 private void OpenMap()
 {
     using (Forms.OpenFileDialog fd = new Forms.OpenFileDialog())
     {
         fd.Title  = "Open a Map...";
         fd.Filter = FILE_TYPE_FILTER;
         if (fd.ShowDialog() == Forms.DialogResult.OK)
         {
             try
             {
                 string file = fd.FileName;
                 // Map loadedMap = FileReadWriter.ReadFromBinary<Map>(file);
                 CurrentMap = FileReadWriter.ReadFromBinary <TentativeTitle.Maps.Map>(file);
                 DefaultValues();
             }
             catch (Exception ex)
             {
                 Forms.MessageBox.Show("Could not read file: " + ex.Message);
             }
         }
     }
 }