コード例 #1
0
  public void setConnected(boolean connected) {
    if (connected) {
      currentConnectStatus = ConnectStatusEnum.CONNECTED;
    } else {
      currentConnectStatus = ConnectStatusEnum.NOT_CONNECTED;
    }

    queueBattleEntries.clear();

    List<BattleEntry> entries = BattleSingleton.getInstance().getEntries(BattleSingleton.PLAYER1);

    int uniqueId = 1;

    for (BattleEntry entry : entries) {
      BattleCommunicationObject sendEntry = new BattleCommunicationObject();
      sendEntry.setAction(CommAction.ADD_ENTRY);
      sendEntry.setBattleEntry(entry);

      if (entry.hasDamageGrid()) {
        // assign unique ID to grid, to ensure no mismatch
        if (((MultiPVModel) entry).getDamageGrid().getUniqueId() == 0) {
          ((MultiPVModel) entry).getDamageGrid().setUniqueId(uniqueId++);
        }
      }
      enqueueBattleEntry(sendEntry);
    }
  }
コード例 #2
0
  private void handleIncomingDamageFromBT(DamageGrid damageGrid) {

    List<BattleEntry> entries = BattleSingleton.getInstance().getEntries(BattleSingleton.PLAYER2);

    int targetId = damageGrid.getUniqueId();
    Log.e(TAG, "target id = " + targetId);

    for (BattleEntry entry : entries) {
      Log.d(TAG, "found player2 entries = " + entry.toString());
      if (entry.hasDamageGrid()) {
        DamageGrid targetGrid = ((MultiPVModel) entry).getDamageGrid();
        Log.d(TAG, "grid id = " + targetGrid.getUniqueId());
        if (targetId == targetGrid.getUniqueId()) {
          Log.d(TAG, "found target grid = " + targetGrid);
          targetGrid.copyStatusFrom(damageGrid);
        }
      }
    }
  }