Package transientlibs.preui.agents.rendering

Source Code of transientlibs.preui.agents.rendering.GDXGlobalStrategyMapDrawAgent

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.preui.agents.rendering;

import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import transientlibs.slick2d.util.Log;

import transientlibs.processors.misc.Detonator;
import transientlibs.preui.objects.states.TransientGame;
import transientlibs.maps.container.TransientAssembledMap;
import transientlibs.maps.container.TiledMapGDXContainer;
import transientlibs.maps.entities.Landmark;
import transientlibs.maps.utils.grid.FOVScreenGrid;
import transientlibs.maps.utils.grid.UnitScreenGrid;
import transientlibs.preui.objects.gui.interfaces.IFont;
import transientlibs.preui.objects.gui.interfaces.IImage;
import transientlibs.preui.objects.states.IState;

/**
*
* @author alta
*/
public class GDXGlobalStrategyMapDrawAgent extends GDXGenericStateDrawAgent {

    public int screenSizeY;
    private OrthographicCamera camera;
    public TiledMapGDXContainer map;
    //public SpriteBatch spriteBatch;
    public TransientGame game;
    public IFont font;
    //public IState state;
   
    int fogX;
    int fogY;
   
    public IImage fog;
   
    private TiledMapRenderer mapRenderer;



    public GDXGlobalStrategyMapDrawAgent(TransientGame setGame, TransientAssembledMap setMap, IState setState) {
        super (setState);
        game = setGame;
       
        screenSizeY = Detonator.INSTANCE.ScreenSizeY;

        map = (TiledMapGDXContainer) setMap;
        //Matrix4 projection = new Matrix4();
        //projection.setToOrtho(0, game.screenSizeX, game.screenSizeY, 0, -1, 1);

        fog = Detonator.INSTANCE.imageProvider.getImage("fog");
       
       
        camera = (OrthographicCamera) map.camera;
        //map.camera = camera;
     
        //Log.info("Map: "+(map != null));
        //Log.info("Internal Map: "+(map.getTiledMapGDX() != null));
        //Log.info("Internal Map2: "+(map.getTiledMapGDX().gdxMap != null));
       
        mapRenderer = new OrthogonalTiledMapRenderer(map.getTiledMapGDX().gdxMap);
        mapRenderer.setView(camera);       
       
        //spriteBatch = new SpriteBatch(100);
       
        font = Detonator.INSTANCE.fontProvider.getFont("djvu_16_sans");
        font.setBatch(spriteBatch);
        //spriteBatch.setProjectionMatrix(projection);
       
    }

    public void draw(TextureRegion region, float x, float y) {
        //int width = region.getRegionWidth();
        //if (width < 0) {
        //    width = -width;
        //}
        //spriteBatch.draw(region, x, screenSizeY - y - region.getRegionHeight(), width, region.getRegionHeight());
        spriteBatch.draw(region, x, screenSizeY - y - region.getRegionHeight());
    }


   
    @Override
    public void process() {     
       
        mapRenderer.setView(camera);
        mapRenderer.render();
       
        spriteBatch.begin();
       

        //Log.info("Landmark count:"+ map.landmarks.size());
       
        for (Landmark l : map.landmarks) {
            float x = l.getScreenCoords().x - camera.position.x;
            float y = l.getScreenCoords().y - camera.position.y;
           
            //Log.info("ScreenCoords: "+l.getScreenCoords().toRoundedString());
            //Log.info("MapCoords: "+l.mapCoords.toRoundedString());
            //Log.info("Camera: "+camera.position.toString());
           
            //l.draw(spriteBatch);
           
            draw (l.getImage().getAtlasRegion(), l.mapCoords.x, l.mapCoords.y);
        }       
 
     
        spriteBatch.end();       
       
        super.process();
       
        spriteBatch.begin();
        //font.drawString(50, 50, "MapCoords: "+player.getMapCoords().toRoundedString(), null);
        //font.drawString(50, 100, "ScreenCoords: "+player.getScreenCoords().toRoundedString(), null);
        spriteBatch.end();


    }
}
TOP

Related Classes of transientlibs.preui.agents.rendering.GDXGlobalStrategyMapDrawAgent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.