Example #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()
        {
            TileMap map = new TileMap(this,Registry.Lookup<Scenegraph>(), @"Content\SampleTileMap.tmx");

            Tank tank = new Tank(this,map,map);
            tank.SetLocalPosition(new Vector2(GraphicsDevice.Viewport.Width/2,GraphicsDevice.Viewport.Height/2));
               // tank.SetTurretRotation((float)Math.PI / 8);
            foreach (Vector2 cellPos in map.GetCellsWithProperty("placement", "Item"))
            {
                int itemIdx = map.GetTileIndex("placement",cellPos);
                string itemType = map.GetTileProperties(itemIdx)["Item"];
                switch (itemType)
                {
                    case "Turret":
                        BasicTilemapSprite turret= new BasicTilemapSprite(map,map,Content.Load<Texture2D>(@"Textures/TankTurret"));
                        turret.SetLocalCellPosition(cellPos);
                        tank.CollidesWith(turret);
                        break;
                }
            }
            // TODO: use this.Content to load your game content here
        }
Example #2
0
        /// <summary>
        /// This wil create the tile map and add it to the scenegraph,
        /// then create the tan kand add it as a child of the tilemap.
        /// </summary>
        protected override void LoadContent()
        {
            // This  creates the tilemap
            // The first paremeter is a refence to the game, used to load
            // content
            // The second parameter is the parent object of the tilemap in
            // the scenegraph.  The scenegraph itself acts as the root parent,
            // so we fetch it from the registry and pass it in
            TileMap map = new TileMap(this,Registry.Lookup<Scenegraph>(), @"Content\SampleTileMap.tmx");

            // This creates the tank.
            // The first paremeter is a refence to the game, used to load
            // content
            // The second parameter is again the parent object,
            // in this case the tile map.
            // The third parameter is the TileMap this tank is on.
            // (It happens to be the parent but it wont encessarily alwaays be)
            // The tnak uses this to scroll the map when it gets near an edge
            Tank tank = new Tank(this,map,map);
            tank.SetLocalPosition(new Vector2(GraphicsDevice.Viewport.Width/2,GraphicsDevice.Viewport.Height/2));
        }