コード例 #1
0
ファイル: MapData.java プロジェクト: Rthe1st/Pirates
 // this should replace isSpaceOccupied, allowing "logic" to be down inside
 // object class
 // this will return nulls if key not present
 public CordData getInfoOnCords(Cords cords) {
   // this would be so much better if goMaps were in a list
   CordData cordData =
       new CordData(
           shipMap.get(cords), enemyMap.get(cords), tileMap.get(cords), mineMap.get(cords));
   return cordData;
 }
コード例 #2
0
ファイル: MapData.java プロジェクト: Rthe1st/Pirates
 // this features super hack reflection, to get static encode_value
 private String encodeCords(int x, int y) {
   String encodedCords = "";
   Cords cords = new Cords(x, y);
   // yet more evidence gameObject maps should be in an array/metamap
   GameObject[] cordsGameObjects =
       new GameObject[] {tileMap.get(cords), enemyMap.get(cords), shipMap.get(cords)};
   GameObject currentGameObject = cordsGameObjects[0];
   if (currentGameObject != null) {
     encodedCords += getGameObjectEncodeValue(currentGameObject);
   }
   for (int i = 1; i < cordsGameObjects.length; i++) {
     currentGameObject = cordsGameObjects[i];
     if (currentGameObject != null) {
       encodedCords += ":";
       encodedCords += getGameObjectEncodeValue(currentGameObject);
       encodedCords += currentGameObject.getEncodedParameters();
     }
   }
   return encodedCords;
 }