public override void init()
        {


            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;
            String mediaDir = CommandosUI.Instance.MediaDir;
            Terrain terrain = new Terrain(
                mediaDir+"Heightmaps\\"+"HeightmapParedes.jpg",
                mediaDir + "Heightmaps\\"+"TexturaParedes.jpg",
                10f,
                0.4f);

            nivel = new Level(terrain);
           

            commando = new Commando(terrain.getPosition(200, 200));
            nivel.add(commando);
            commando.Life.Infinite = true;


           
            Vector3[] waitpoints = new Vector3[1];
            terrain.heightmapCoordsToXYZ(new Vector2(60, 60), out waitpoints[0]);
            //terrain.heightmapCoordsToXYZ(new Vector2(22, 80), out waitpoints[1]);
            //terrain.heightmapCoordsToXYZ(new Vector2(10, 37), out waitpoints[2]);

            
            enemigo = new Enemy(new Vector3(0,0,0));
            nivel.add(enemigo);
            

            //Seleccion multiple
            selection = new Selection(nivel.Characters, nivel.Terrain);

            //Movimiento por picking
            picking = new MovementPicking(nivel.Terrain);

            GuiController.Instance.Modifiers.addFloat("RadioVision", 0, 500, 100);
            GuiController.Instance.Modifiers.addFloat("AnguloVision", 0, 90, 45);
            GuiController.Instance.Modifiers.addBoolean("Direccion", "Mostrar", false);
            GuiController.Instance.Modifiers.addVertex3f("posicionEnemigo", new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), new Vector3(400, 0, 100));
            GuiController.Instance.Modifiers.addFloat("RotacionEnemigo", 0, 360, 0);



            previousAngle = 0;

            new StandardCamera();
            nivel.CullingEnabled = false;
        }
        public override void init(){
        

            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;
            String mediaDir = GuiController.Instance.AlumnoEjemplosMediaDir;
            nivel = new Level(
                new Terrain(CommandosUI.Instance.MediaDir + "Heightmaps\\HeightmapPlano.jpg",
                    GuiController.Instance.ExamplesMediaDir + "Texturas\\tierra.jpg",
                    10f,
                    1f
                    )
                 );
            pared = new Wall(new Vector3(0,0,0), new Vector3(200, 50, 10));
                        
            pj = new Commando(new Vector3(0, 0, -40));
            pj.Representation.AutoTransformEnable = true;


            enemigo = new Enemy(new Vector3(0, 0, 40));
            enemigo.ShowConeDirection = true;
            nivel.add(pared);
            nivel.add(enemigo);
            nivel.add(pj);

            GuiController.Instance.Modifiers.addFloat("AlturaPared", 10, 60, 10);
            GuiController.Instance.Modifiers.addFloat("RadioVision", 0, 500,100);
            GuiController.Instance.Modifiers.addFloat("AnguloVision", 0, 90, 45);
            GuiController.Instance.Modifiers.addBoolean("Direccion","Mostrar",false);
            //GuiController.Instance.RotCamera.targetObject(enemigo.BoundingBox);
            GuiController.Instance.RotCamera.CameraDistance = 200;
            GuiController.Instance.Modifiers.addVertex3f("posicionTarget", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, -20));

            Modifiers.initialize();


            GuiController.Instance.Modifiers.addBoolean("Cilindros", "Ver cilindros", false);
            Modifiers.Instance.bind("Cilindros", typeof(Character), "RenderCylinder");
            GuiController.Instance.Modifiers.addBoolean("Agachado", "Sí", false);
            Modifiers.Instance.bind("Agachado", this, "Crouch");
            Modifiers.Instance.bind("RadioVision", enemigo,"VisionRadius");
            Modifiers.Instance.bind("Direccion", enemigo, "ShowConeDirection");
            Modifiers.Instance.bind("posicionTarget", pj, "Position");







        }
 private void disposeAll()
 {
     if(controlPanel!=null) controlPanel.dispose();
     if(level!=null)level.dispose();
     Modifiers.clear();
     level = null;
     controlPanel = null;
 }
        private void loadLevel(string newLevel)
        {
            disposeAll();

            GuiController.Instance.Modifiers.clear();
            GuiController.Instance.UserVars.clearVars();

            currentLevel = newLevel;

            XMLLevelParser levelParser = new XMLLevelParser(newLevel, CommandosUI.Instance.MediaDir);
            level = levelParser.getLevel();


            LevelMap map = level.Map;
            map.setMask(TextureLoader.FromFile(CommandosUI.Instance.d3dDevice, CommandosUI.Instance.MediaDir + "Mapa\\mask.jpg"));
            map.setFrame(TextureLoader.FromFile(CommandosUI.Instance.d3dDevice, CommandosUI.Instance.MediaDir + "Mapa\\frame.png"));
            map.Width = 2 * level.Map.Height;
            map.Height = 1.5f * level.Map.Height;
            map.Position = new Vector2(CommandosUI.Instance.ScreenWidth - level.Map.Width , 0);


            defaultRenderer = level.Renderer;
            shadowRenderer = new ShadowRenderer();

    
            //Movimiento por picking
            picking = new MovementPicking(level.Terrain);

            //Seleccion multiple
            selection = new Selection(level.Characters, level.Terrain);
             
            //Inicializar camara
            CommandosUI.Instance.Camera = new PCamera(new Vector3(0, 0, 150), level.Terrain);


            //Panel de control in game
            controlPanel = new GraphicalControlPanel(CommandosUI.Instance.MediaDir + "Sprites\\panel2.jpg");
            controlPanel.addCommand(new SwitchCrouch(selection.getSelectedCharacters()), CommandosUI.Instance.MediaDir + "Sprites\\crouch.png");
            controlPanel.addCommand(new StandBy(selection.getSelectedCharacters()), CommandosUI.Instance.MediaDir + "Sprites\\cancel.png");
            CommandosUI.Instance.Panel = controlPanel;

            foreach (Commando c in level.Commandos)
                controlPanel.addSelectionButton(c, selection);

            setAndBindModifiers();


        }
 public void setLevel(Level _level)
 {
     this.level = _level;
 }