package server.player;
import client.game.Game;
import server.sprite.Sprite;
import general.datastructures.Rectangle;
import general.datastructures.Vector2f;
import general.helperclasses.Math;
public class HumanPlayer extends Player{
public HumanPlayer(Game g, ThreadGroup parent, String name, Vector2f mc_spawnpoint) {
super(g, parent, name, mc_spawnpoint);
}
public boolean selectSprite(Vector2f sc_coords)
{
Thread[] threads = new Thread[tg_units.activeCount()];
tg_units.enumerate(threads);
selectedSprite = null;
for(Thread t:threads)
{
try
{
Sprite s = (Sprite)t;
Rectangle col = Math.worldToScreen(s.getCollisionRectangle(),game.getViewport());
if(col.isInside(sc_coords))
{
this.selectedSprite = s;
System.out.println(s.toString());
return true;
}
}catch (Exception e) {
//No Sprite
}
}
System.out.println("Keine Einheit ausgewaehlt");
return false;
}
public Sprite getSelectedSprite()
{
return selectedSprite;
}
public boolean spriteAction(Vector2f sc_coords)
{
if(selectedSprite!=null)
{
return game.getUnitManager().moveSprite(selectedSprite, sc_coords);
}
else
{
return false;
}
}
}