Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. package gameplayer.view;
  2.  
  3. import gameengine.controller.Game;
  4. import gameengine.model.AttributeType;
  5. import voogasalad.util.hud.source.*;
  6.  
  7. public class TLGCSValueFinder implements IValueFinder {
  8.  
  9. private Game data; //for other projects, your data will be a different class
  10.  
  11. @Override
  12. public Property<?> find(String key) {
  13. Property<?> ret = null;
  14. switch (key.toLowerCase()) {
  15. case "points":
  16. ret = data.getCurrentLevel().getMainCharacter().getAttribute(AttributeType.POINTS).getProperty();
  17. break;
  18. case "health":
  19. ret = data.getCurrentLevel().getMainCharacter().getAttribute(AttributeType.HEALTH).getProperty();
  20. break;
  21. case "ammo":
  22. //
  23. break;
  24. default:
  25. ret = new Property<String>("Value Not Found", key);
  26. break;
  27. }
  28.  
  29. return ret;
  30. }
  31.  
  32. @Override
  33. public void setDataSource(Object dataSource) throws IllegalArgumentException {
  34. if (dataSource instanceof Game) {
  35. this.data = (Game) dataSource;
  36. } else {
  37. throw new IllegalArgumentException();
  38. }
  39. }
  40.  
  41. @Override
  42. public void setController(HUDController controller) {
  43. // TODO Auto-generated method stub
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement