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
        }