Esempio n. 1
0
  /**
   * BATTLEボタンを画面に設定する
   *
   * @param type
   */
  public void setDealButton() {

    Button button = new Button(this.activity);
    button.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // 戦闘シーンへ移動するため、値を戻す
            BattleSceneCardSelection.threeCardselected = false;

            // 戦闘シーンへ移動
            callChangeNexrScene();
          }
        });

    BattleLayout.LayoutParams params =
        new BattleLayout.LayoutParams(
            BattleLayout.LayoutParams.MATCH_PARENT, this.activity.baseLayout.getHeight() * 1 / 3);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.setMargins((int) (0), (int) (this.activity.baseLayout.getHeight() * 2 / 3), 0, 0);

    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.battle_battle_button);

    // 戦闘ベース部品にcard追加する
    this.activity.baseLayout.addView(button, params);
  }
Esempio n. 2
0
  /**
   * 合計表示を画面に表示する
   *
   * @param left
   * @param top
   */
  public void viewTotal(int left, int top) {

    // Densityの値を取得
    float tmpDensity = this.activity.getResources().getDisplayMetrics().density;

    // CARD用View取得
    LinearLayout totalView =
        (LinearLayout)
            ((LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.battle_totalpoint, null);

    BattleLayout.LayoutParams cartParams =
        new BattleLayout.LayoutParams((int) (100 * tmpDensity), (int) (120 * tmpDensity));
    cartParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    cartParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    cartParams.setMargins((int) (left * tmpDensity), (int) (top * tmpDensity), 0, 0);

    // 攻撃力合計
    ((TextView) totalView.findViewById(R.id.battle_total_attack)).setText("0");

    // 守備力合計
    ((TextView) totalView.findViewById(R.id.battle_total_defense)).setText("0");

    // 戦闘ベース部品にカード詳細を追加する
    this.activity.baseLayout.addView(totalView, cartParams);
  }
Esempio n. 3
0
  /** 選択カードの確認拡大表示 */
  private void viewSelectedBigCardDisp() {
    // 表示を一旦クリア
    this.finish();
    this.bigCards.clear();

    // 選択した3つを中央に表示
    // 多少拡大する
    ArrayList<BattleCardView> cards = this.activity.myInfo.getSelectedCard();

    int posX = 10;
    int posY = 160;
    float tmpDensity = this.activity.getResources().getDisplayMetrics().density;
    int myCardMarginX =
        (int)
            ((new Float(this.activity.baseLayout.getWidth()) / tmpDensity - (new Float(posX) * 2))
                / 3);

    int length = cards.size();
    for (int i = 0; i < length; i++) {
      // Densityの値を取得

      BattleCardView viewCard =
          (BattleCardView)
              ((LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                  .inflate(R.layout.my_cards_big, null);

      viewCard.setControlActivity(this.activity);

      BattleLayout.LayoutParams cartParams =
          new BattleLayout.LayoutParams(
              (int) (this.activity.getResources().getDimensionPixelSize(R.dimen.big_card_width)),
              (int) (this.activity.getResources().getDimensionPixelSize(R.dimen.big_card_height)));
      cartParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      cartParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
      cartParams.setMargins(
          (int) ((posX + (myCardMarginX * i)) * tmpDensity), (int) (posY * tmpDensity), 0, 0);
      viewCard.setBeetleCard(cards.get(i).getCardInfo());
      viewCard.setUpFlag(true);
      viewCard.flippedCardFace();

      // 参照を保持する
      this.bigCards.add(viewCard);

      // 戦闘ベース部品にcard追加する
      this.activity.baseLayout.addView(viewCard, 0, cartParams);
    }

    // 合計パネルを右上に表示
    this.viewTotal(200, 10);
    this.calcAndViewTotal(cards);

    this.setDealButton();
  }
Esempio n. 4
0
  /**
   * カードを表示する
   *
   * @param type
   */
  public void displayCards(int type) {

    ArrayList<BattleCardView> viewCards = null;

    // 自分のカードを全部取得
    CardBattlerInfo info = null;
    if (type == 0) {
      info = this.activity.myInfo;
    } else {
      info = this.activity.enemyInfo;
    }
    viewCards = info.getAllCards();

    // Densityの値を取得
    float tmpDensity = this.activity.getResources().getDisplayMetrics().density;

    int length = viewCards.size();
    for (int i = 0; i < length; i++) {

      // 手札の場合、のみ表示する
      if ((info.getStatus(viewCards.get(i)) == 1) || (info.getStatus(viewCards.get(i)) == 2)) {
        BattleLayout.LayoutParams cartParams =
            new BattleLayout.LayoutParams(
                (int) (this.activity.getResources().getDimensionPixelSize(R.dimen.card_width)),
                (int) (this.activity.getResources().getDimensionPixelSize(R.dimen.card_height)));
        cartParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        cartParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        cartParams.setMargins(
            (int) (viewCards.get(i).getStartPosLeft() * tmpDensity),
            (int) (viewCards.get(i).getStartPosTop() * tmpDensity),
            0,
            0);

        // 戦闘ベース部品にcard追加する
        this.activity.baseLayout.addView(viewCards.get(i), cartParams);
      }
    }
  }
Esempio n. 5
0
  /**
   * カード詳細を画面に表示する
   *
   * @param left
   * @param top
   */
  public void viewDetailCards(View view, int left, int top) {

    BattleCardView card = (BattleCardView) view;

    // Densityの値を取得
    float tmpDensity = this.activity.getResources().getDisplayMetrics().density;

    // CARD用View取得
    this.myViewCardDerail =
        ((LayoutInflater) this.activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.card_detailview, null);

    int posLeft = (int) (this.activity.baseLayout.getWidth() / 2 - 266 * tmpDensity / 2);

    BattleLayout.LayoutParams cartParams =
        new BattleLayout.LayoutParams((int) (266 * tmpDensity), (int) (400 * tmpDensity));
    cartParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    cartParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    cartParams.setMargins((int) (posLeft), (int) (top * tmpDensity), 0, 0);

    // 名前
    ((TextView) this.myViewCardDerail.findViewById(R.id.carddetail_name))
        .setText(card.getCardInfo().getName());

    // 画像設定
    ((ImageView) this.myViewCardDerail.findViewById(R.id.carddetail_icon))
        .setImageResource(card.getCardInfo().getImageResourceId(this.activity));

    // 属性設定
    CardAttribute attr = card.getCardInfo().getAttribute();
    if (attr == CardAttribute.FIRE) {
      ((ImageView) this.myViewCardDerail.findViewById(R.id.carddetail_attrribute))
          .setImageResource(R.drawable.fire);
    } else if (attr == CardAttribute.WATER) {
      ((ImageView) this.myViewCardDerail.findViewById(R.id.carddetail_attrribute))
          .setImageResource(R.drawable.water);
    } else if (attr == CardAttribute.WIND) {
      ((ImageView) this.myViewCardDerail.findViewById(R.id.carddetail_attrribute))
          .setImageResource(R.drawable.wind);
    }

    int type = card.getCardInfo().getType();
    if (type == 3) {

      // 背景設定
      ((RelativeLayout) this.myViewCardDerail.findViewById(R.id.carddetail_bg))
          .setBackgroundResource(R.drawable.card_red);

      // 攻、守
      // 表示文字設定
      ((TextView) this.myViewCardDerail.findViewById(R.id.carddetail_atk))
          .setText("攻撃:" + Integer.toString(card.getCardInfo().getAttack()));
    }
    if (type == 4) {

      // 背景設定
      ((RelativeLayout) this.myViewCardDerail.findViewById(R.id.carddetail_bg))
          .setBackgroundResource(R.drawable.card_blue);

      // 攻、守
      // 表示文字設定
      ((TextView) this.myViewCardDerail.findViewById(R.id.carddetail_def))
          .setText("守備:" + Integer.toString(card.getCardInfo().getDefense()));
    }

    // 説明
    ((TextView) this.myViewCardDerail.findViewById(R.id.carddetail_intoro))
        .setText("説明:" + card.getCardInfo().getIntroduction());

    // 戦闘ベース部品にカード詳細を追加する
    this.activity.baseLayout.addView(this.myViewCardDerail, cartParams);
  }
Esempio n. 6
0
  @Override
  public void moveCard(BattleCardView view, int action) {

    if (this.activity.myInfo.getStatus(view) == null) {

      for (BattleCardView card : this.bigCards) {
        if ((view.equals(card))
            && (action == 1)
            && (BattleSceneCardSelection.threeCardselected == true)) {
          // カードと押されたカードが同じで、且つ下げイベントで且つ、3枚選択されている状態の場合

          // 下げるビューを見つける。

          view = this.searchCardFromBigCard(card);
          if (view != null) {
            break;
          }
        }
      }
      if (this.activity.myInfo.getStatus(view) == null) {
        // 入れ替えてもなおNULLなら何もしない
        return;
      }
    }

    int status = this.activity.myInfo.getStatus((BattleCardView) view);
    // カードのステータスが 手札、手札から選択の場合、上げ下げ可能
    // Densityの値を取得
    float tmpDensity = this.activity.getResources().getDisplayMetrics().density;

    if (status == 1) {
      // カードを押さえてカードより上の座標ずらしたら、カードを上にずらす。
      if ((action == 0) && (BattleSceneCardSelection.threeCardselected == false)) {
        BattleLayout.LayoutParams params = (BattleLayout.LayoutParams) view.getLayoutParams();
        params.setMargins(
            (int) ((view).getStartPosLeft() * tmpDensity),
            (int) (((view).getStartPosTop() - 20) * tmpDensity),
            0,
            0);
        view.setLayoutParams(params);

        // 選択
        this.activity.myInfo.selectCard(view);

        // 選択状況を解析
        this.analyzeSelectCards();
      }
    } else if (status == 2) {
      // カードを押さえてカードより下の座標にずらしたらカードを元の位置にに戻す
      if (action == 1) {

        if (BattleSceneCardSelection.threeCardselected == true) {

          this.rollbackBefoeThreeSelect();
        }

        BattleLayout.LayoutParams params = (BattleLayout.LayoutParams) view.getLayoutParams();
        params.setMargins(
            (int) ((view).getStartPosLeft() * tmpDensity),
            (int) (((view).getStartPosTop()) * tmpDensity),
            0,
            0);
        view.setLayoutParams(params);

        // 選択解除
        this.activity.myInfo.dealCard(view);

        // 選択状況を解析
        this.analyzeSelectCards();
      }
    }
  }