public void removeEntity() { Position entityPosition = _map.getCell(_posSelected).getPrimaryEntity(); int entityID = _map.getEntityID(entityPosition); EntityType entity = _map.getEntity(entityID).getType(); Position[] posList = new Position[_preferences.getEntityHeight(entity) * _preferences.getEntityWidth(entity)]; int i = 0; for (int x = entityPosition.getX(); x < (entityPosition.getX() + _preferences.getEntityWidth(entity)); x++) for (int y = entityPosition.getY(); y < (entityPosition.getY() + _preferences.getEntityHeight(entity)); y++) { posList[i] = new Position(x, y); i++; } if (_map.removeEntity(posList, entityID)) { notifyRemoveEntity(posList); notifyCellDeSelected(); } }
private void notifyNewMapLoaded() { notifyCellDeSelected(); notifyNewMap(_map.getMapWidth(), _map.getMapHeight()); _posSelected = null; Position pos = null; for (int x = 0; x < _map.getMapWidth(); x++) for (int y = 0; y < _map.getMapHeight(); y++) { pos = new Position(x, y); notifyCellChanged(pos, _map.getCell(pos).getType()); int entityID = _map.getCell(pos).getEntity(); if (entityID != 0) { Position entityPos = _map.getCell(pos).getPrimaryEntity(); EntityType entityType = _map.getEntity(entityID).getType(); Position[] posList = new Position [_preferences.getEntityHeight(entityType) * _preferences.getEntityWidth(entityType)]; int i = 0; for (int xEntity = entityPos.getX(); xEntity < (entityPos.getX() + _preferences.getEntityWidth(entityType)); xEntity++) for (int yEntity = entityPos.getY(); yEntity < (entityPos.getY() + _preferences.getEntityHeight(entityType)); yEntity++) { posList[i] = new Position(xEntity, yEntity); i++; } notifyNewEntity(posList, entityType); } } }
private void notifyShowEntityMessage() { String message; if (_map.getCell(_posSelected).getEntity() > 0) message = "Información de la entidad:"; else message = "Casilla sin entidad"; for (ControllerListener listener : _listeners) { listener.showEntityMessage(message); } }
private void notifyAllSelectChanges() { notifyCellSelected(); notifyShowCellType(); notifyShowEntityMessage(); if (_map.getCell(_posSelected).getEntity() > 0) { Entity entity = _map.getEntity(_map.getEntityID(_posSelected)); Set<String> paramNames = entity.getParamNames(); for (String name : paramNames) { notifyShowEntityParameter(name, entity.getParameter(name)); } } }
private void notifyShowCellType() { for (ControllerListener listener : _listeners) { listener.showCellType(_map.getCell(_posSelected).getType().getType()); } }