示例#1
0
  public void init(float posX, float posY, int type, float angle) {
    this.type = type;

    float width = widths.get(type, 0.1f);
    float height = heights.get(type, 0.1f);

    bounds.set(posX - width / 2F, posY, width, height);
    position.set(posX - width / 2F, posY);
    velocity.set(0, speeds.get(type, 4f));
    velocity.setAngle(90f + angle);
    this.damage = damages.get(type, 2);
    alive = true;
    upgradeable = upgradeables.get(type);
  }
示例#2
0
  public static void initialize(JSONArray shotDefs) throws JSONException {
    for (int i = 0; i < shotDefs.length(); i++) {
      JSONObject shotDef = shotDefs.getJSONObject(i);
      int type = shotDef.getInt("type");
      types.add(type);

      widths.put(type, (float) shotDef.getDouble("width"));
      heights.put(type, (float) shotDef.getDouble("height"));
      speeds.put(type, (float) shotDef.getDouble("speed"));
      damages.put(type, shotDef.getInt("damage"));
      textures.put(type, shotDef.getString("texture"));
      upgradeables.put(type, shotDef.getBoolean("upgradeable"));
    }
  }
示例#3
0
 public void remove() {
   if (currentIndex == INDEX_ZERO && map.hasZeroValue) {
     map.hasZeroValue = false;
   } else if (currentIndex < 0) {
     throw new IllegalStateException("next must be called before remove.");
   } else if (currentIndex >= map.capacity) {
     map.removeStashIndex(currentIndex);
     nextIndex = currentIndex - 1;
     findNextIndex();
   } else {
     map.keyTable[currentIndex] = EMPTY;
   }
   currentIndex = INDEX_ILLEGAL;
   map.size--;
 }
示例#4
0
 public boolean equals(Object obj) {
   if (obj == this) return true;
   if (!(obj instanceof IntFloatMap)) return false;
   IntFloatMap other = (IntFloatMap) obj;
   if (other.size != size) return false;
   if (other.hasZeroValue != hasZeroValue) return false;
   if (hasZeroValue && other.zeroValue != zeroValue) {
     return false;
   }
   int[] keyTable = this.keyTable;
   float[] valueTable = this.valueTable;
   for (int i = 0, n = capacity + stashSize; i < n; i++) {
     int key = keyTable[i];
     if (key != EMPTY) {
       float otherValue = other.get(key, 0f);
       if (otherValue == 0f && !other.containsKey(key)) return false;
       float value = valueTable[i];
       if (otherValue != value) return false;
     }
   }
   return true;
 }
示例#5
0
 public void putAll(IntFloatMap map) {
   for (Entry entry : map.entries()) put(entry.key, entry.value);
 }
示例#6
0
 public float getButtonAmount(int buttonCode) {
   return buttons.get(buttonCode, 0);
 }
示例#7
0
 @Override
 public boolean getButton(int buttonCode) {
   return buttons.get(buttonCode, 0) >= 0.5f;
 }