Parser hat seperaten Update und schreibt Player nicht jedes mal neu

This commit is contained in:
Daniel Herrmann
2014-05-15 13:24:47 +02:00
parent 6fc2caa10b
commit cbfa07675b
3 changed files with 40 additions and 4 deletions

View File

@@ -77,11 +77,21 @@ namespace WorldOfPeacecraft
return Players[playerId];
}
public Dictionary<int, Player> getPlayerList()
{
return Players;
}
public Dragon getDragon (int dragonId)
{
return Dragons[dragonId];
}
public Dictionary<int, Dragon> getDragonList()
{
return Dragons;
}
public Map getMapObject ()
{
return Map;

View File

@@ -300,11 +300,22 @@ namespace WorldOfPeacecraft
private void ProcessPlayer (Block playerBlock)
{
lock (Backend) {
Backend.SetPlayer (MapPlayer (playerBlock));
}
Backend.RefreshGui ();
int id = MapPlayer(playerBlock).GetId();
if (Backend.getPlayer(id) == null)
{
lock (Backend)
{
Backend.SetPlayer(MapPlayer(playerBlock));
}
Backend.RefreshGui();
}
else
{
MapPlayerUPD(playerBlock);
}
}
private void ProcessMapcell (Block mapcellBlock)
{
@@ -405,6 +416,21 @@ namespace WorldOfPeacecraft
int y = playerBlock.GetIntValue (ValueY);
return new Player (id, x, y, desc, busy, score);
}
private void MapPlayerUPD(Block playerBlock)
{
int id = playerBlock.GetIntValue(ValueId);
int score = playerBlock.GetIntValue(ValuePoints);
bool busy = playerBlock.GetBoolValue(ValueBusy);
string desc = playerBlock.GetStringValue(ValueDescription);
int x = playerBlock.GetIntValue(ValueX);
int y = playerBlock.GetIntValue(ValueY);
Backend.getPlayer(id).SetScore(score);
Backend.getPlayer(id).SetDesc(desc);
Backend.getPlayer(id).SetX(x);
Backend.getPlayer(id).SetY(y);
}
private Tile MapMapcell (Block cellBlock)
{