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 SelectionButton(Character _ch, Selection _selection)
 {
     this.ch = _ch;
     this.selectionRef = _selection;
 }
 /// <summary>
 /// Agrega un boton de seleccion de personaje al panel
 /// </summary>
 public void addSelectionButton(Character ch, Selection selection)
 {
     this.buttons.Add(new SelectionButton(ch, selection));
 }
        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();


        }