示例#1
0
  public void switchPokemon(View view) {
    clearBottom();
    cancelAttack.setVisibility(View.VISIBLE);
    Pokemon1.setText(user.getPokemonTeam().get(0).getName());
    Pokemon2.setText(user.getPokemonTeam().get(1).getName());
    Pokemon3.setText(user.getPokemonTeam().get(2).getName());
    if (user.getPokemonTeam().get(0).getHealth() > 0) {
      Pokemon1.setVisibility(View.VISIBLE);
    }
    if (user.getPokemonTeam().get(1).getHealth() > 0) {
      Pokemon2.setVisibility(View.VISIBLE);
    }
    if (user.getPokemonTeam().get(2).getHealth() > 0) {
      Pokemon3.setVisibility(View.VISIBLE);
    }
    if (user.getPokemonTeam().get(0) == userPokemon) {
      Pokemon1.setVisibility(View.INVISIBLE);
    }
    if (user.getPokemonTeam().get(1) == userPokemon) {
      Pokemon2.setVisibility(View.INVISIBLE);
    }
    if (user.getPokemonTeam().get(2) == userPokemon) {
      Pokemon3.setVisibility(View.INVISIBLE);
    }

    return;
  }
示例#2
0
  public void hideText4(View view) { // Shows at the start of the game
    if (messageReceived.get()) {
      messageReceived.set(false);
      enemy = new Player(enemyFirst, enemySecond, enemyThird);
      enemyPokemon = enemy.getPokemonTeam().get(0);
      SetEnemy();

      PopUp4.setVisibility(View.INVISIBLE);
      readyUp();
    }
  }
示例#3
0
  public void launchText4(String text) {
    clearBottom();
    if (messageReceived.get()) {
      messageReceived.set(false);
      enemy = new Player(enemyFirst, enemySecond, enemyThird);
      enemyPokemon = enemy.getPokemonTeam().get(0);
      SetEnemy();

      PopUp4.setVisibility(View.INVISIBLE);
      readyUp();
    } else {
      PopUp4.setText("Waiting on Opponent to start..."); // + " dbg4");
      PopUp4.setVisibility(View.VISIBLE);
    }
  }
示例#4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    messageReceived = new AtomicBoolean(false);
    messageReceived.getAndSet(false);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_battle);
    // ConnectivityManager connMgr = (ConnectivityManager)
    // getSystemService(Context.CONNECTIVITY_SERVICE);
    // NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    fragment = new BluetoothChatFragment();
    fragment.copy(MainActivity.fragment, 1);
    if (savedInstanceState == null) {
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      transaction.replace(R.id.game_content_fragment, fragment);
      transaction.commit();
    }

    firstTime = true;
    Intent intent = getIntent();
    String OtherPokemon = intent.getStringExtra(MainActivity.GAME_START);
    String gameType = intent.getStringExtra(MainActivity.GAME_TYPE);

    // Initialize Globals
    currentAttack = -1;
    MainText = (TextView) findViewById(R.id.MainText);
    UserName = (TextView) findViewById(R.id.UserName);
    UserHealth = (ProgressBar) findViewById(R.id.UserHealth);
    UserImage = (ImageView) findViewById(R.id.UserImage);
    EnemyName = (TextView) findViewById(R.id.EnemyName);
    EnemyHealth = (ProgressBar) findViewById(R.id.EnemyHealth);
    EnemyImage = (ImageView) findViewById(R.id.EnemyImage);
    SwitchButton = (Button) findViewById(R.id.SwitchButton);
    FightButton = (Button) findViewById(R.id.FightButton);
    SurrenderButton = (Button) findViewById(R.id.SurrenderButton);
    ReadyButton = (Button) findViewById(R.id.ReadyButton);
    Attack1 = (Button) findViewById(R.id.Attack1);
    Attack2 = (Button) findViewById(R.id.Attack2);
    Attack3 = (Button) findViewById(R.id.Attack3);
    Pokemon1 = (Button) findViewById(R.id.Pokemon1);
    Pokemon2 = (Button) findViewById(R.id.Pokemon2);
    Pokemon3 = (Button) findViewById(R.id.Pokemon3);
    cancelAttack = (Button) findViewById(R.id.CancelAttack);
    rn = new Random();
    PopUp = (TextView) findViewById(R.id.PopUp);
    PopUp2 = (TextView) findViewById(R.id.PopUp2);
    PopUp3 = (TextView) findViewById(R.id.PopUp3);
    PopUp4 = (TextView) findViewById(R.id.PopUp4);
    PopUp5 = (TextView) findViewById(R.id.PopUp5);
    CloseWindow = true;
    EnemyName.setText("Waiting");

    int pokemonPassedByMain[] = intent.getIntArrayExtra(MainActivity.GAME_POKEMON);

    user = new Player();
    for (int i : pokemonPassedByMain) {
      user.addPokemon(i);
    }

    yourRandom = (int) (Math.random() * 50000);
    userPokemon = user.getPokemonTeam().get(0);
    fragment.sendPokeMessage(
        user.getPokemonNums() + ":set" + gameType.substring(0, 6) + yourRandom);

    // enemy = new Player();

    SwitchButton.setVisibility(View.INVISIBLE);
    SurrenderButton.setVisibility(View.INVISIBLE);
    FightButton.setVisibility(View.INVISIBLE);
    UserHealth.setMax(userPokemon.getStats().getMaxHP());
    UserHealth.setProgress(userPokemon.getHealth());
    UserImage.setImageResource(userPokemon.backPicture);
    UserName.setText(userPokemon.getName());

    if (OtherPokemon.contains(":set")) {
      firstTime = false;
      // TODO:: Edit this code to be expandable (to be able to change the number of pokemon more
      // easily)
      enemyFirst = (int) Integer.parseInt(OtherPokemon.substring(0, 2));
      enemySecond = (int) Integer.parseInt(OtherPokemon.substring(2, 4));
      enemyThird = (int) Integer.parseInt(OtherPokemon.substring(4, 6));
      theirRandom = (int) Integer.parseInt(OtherPokemon.substring(16));
      enemy = new Player(enemyFirst, enemySecond, enemyThird);
      enemyPokemon = enemy.getPokemonTeam().get(0);
      EnemyHealth.setMax(enemyPokemon.getStats().getMaxHP());
      EnemyHealth.setProgress(enemyPokemon.getHealth());
      EnemyImage.setImageResource(enemyPokemon.frontPicture);
      EnemyName.setText(enemyPokemon.getName());
      readyUp();
    } else {
      launchText4("Waiting for opponent");
    }
  }
示例#5
0
 public void userSwitch(int newPmn) {
   userPokemon = user.getPokemonTeam().get(newPmn);
   SetUser();
   ScalePic(false);
   launchText5("You sent out " + userPokemon.getName() + "!");
 }
示例#6
0
 public void EnemySwitch(int newPmn) {
   enemyPokemon = enemy.getPokemonTeam().get(newPmn);
   SetEnemy();
   ScalePic(true);
   launchText5("Your Opponent sent out " + enemyPokemon.getName() + "!");
 }