Android Open Source - Castle-Invaders Score Screen






From Project

Back to project page Castle-Invaders.

License

The source code is released under:

GNU General Public License

If you think the Android project Castle-Invaders listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.noobygames.castleinvaders.screens;
//from  w  w  w .j ava  2  s  . c  o  m
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Vector2;
import com.noobygames.castleinvaders.Assets;
import com.noobygames.castleinvaders.CastleInvaders;
import com.noobygames.castleinvaders.Player;

public class ScoreScreen implements Screen, InputProcessor {

  private CastleInvaders game;
  private Player player;
  private OrthographicCamera camera;
  static final float FRUSTUM_WIDTH = 1280;
  static final float FRUSTUM_HEIGTH = 768;
  private boolean wonLastRound;
  private int earthDragonXP;
  private int fireDragonXP;
  private int iceDragonXP;
  private int touched = 0;
  private Vector2 touchpoint;
  private float timer;

  public ScoreScreen(CastleInvaders game, Player player, Boolean win,
      int earthDragonXP, int fireDragonXP, int iceDragonXP){
    this.game = game;
    this.player = player;
    wonLastRound = win;
    this.earthDragonXP = earthDragonXP;
    this.fireDragonXP = fireDragonXP;
    this.iceDragonXP = iceDragonXP;
    touchpoint = new Vector2();

    game.font.scale(3);
    camera = new OrthographicCamera();
    camera.setToOrtho(false, FRUSTUM_WIDTH, FRUSTUM_HEIGTH);
  }

  @Override
  public void render(float delta) {
    game.batch.begin();
    Gdx.gl.glEnable(GL20.GL_TEXTURE_2D);

    if (touchpoint.x >= -200)
      touched++;

    if (touched >= 2 && timer > 3) {
      game.setScreen(new MainMenuScreen(game, player));
      this.dispose();
    }

    else if (wonLastRound && timer < 6 && timer >= 3)
      drawDragonXP();

    else if (wonLastRound) {
      game.batch.draw(Assets.menuBackground, 0, 0, 1280, 768);
      game.batch.draw(Assets.window, 60, 60, 1160, 648);
      game.font.draw(game.batch, "You won!", 370, 600);
      game.font.draw(game.batch,
          "Coins earned: " + game.prefs.getInteger("level") * 100,
          370, 560);
      if (player.getLevel() % 3 == 0)
        game.font.draw(game.batch, "Gems earned: 1", 370, 520);
      game.font.draw(game.batch,
          "Total Coins: " + game.prefs.getInteger("coins"), 370, 480);
      game.font.draw(game.batch,
          "Total Gems: " + game.prefs.getInteger("gems"), 370, 440);
      game.font.draw(game.batch, "Tap to continue", 370, 250);
    }

    else {
      game.batch.draw(Assets.menuBackground, 0, 0);
      game.batch.draw(Assets.window, 60, 60, 1160, 648);
      game.font.draw(game.batch, "You have been defeated!", 370, 600);
      game.font.draw(game.batch, "Total Coins: " + player.getCoins(),
          370, 490);
      game.font.draw(game.batch, "Total Gems: " + player.getGems(), 370,
          450);
      game.font.draw(game.batch, "Tap to continue", 370, 250);
    }

    timer += Gdx.graphics.getDeltaTime();
    game.batch.end();
  }

  private void drawDragonXP() {
    game.batch.draw(Assets.menuBackground, 0, 0, 1280, 768);
    game.batch.draw(Assets.window, 60, 60, 1160, 648);
    game.font.draw(game.batch, "Firedragon XP earned: " + fireDragonXP,
        100, 500);
    game.font.draw(game.batch,
        "Total Firedragon XP: " + player.getFireDragonXP(), 100, 460);
    game.font.draw(game.batch, "Icedragon XP earned: " + iceDragonXP, 100,
        400);
    game.font.draw(game.batch,
        "Total Icedragon XP: " + player.getIceDragonXP(), 100, 360);
    game.font.draw(game.batch, "Earthdragon XP earned: " + earthDragonXP,
        100, 300);
    game.font.draw(game.batch,
        "Total Earthdragon XP: " + player.getEarthDragonXP(), 100, 260);
  }

  @Override
  public void resize(int width, int height) {
    // TODO Auto-generated method stub

  }

  @Override
  public void show() {
    Gdx.input.setInputProcessor(this);
    Gdx.input.setCatchBackKey(true);
    camera.update();
    game.batch.setProjectionMatrix(camera.combined);

  }

  @Override
  public void hide() {
    Gdx.input.setInputProcessor(null);

  }

  @Override
  public void pause() {
    // TODO Auto-generated method stub

  }

  @Override
  public void resume() {
    // TODO Auto-generated method stub

  }

  @Override
  public void dispose() {
    Gdx.input.setInputProcessor(null);

  }

  @Override
  public boolean keyDown(int keycode) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean keyUp(int keycode) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean keyTyped(char character) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    touchpoint.x = screenX;
    touchpoint.y = screenY;
    return true;
  }

  @Override
  public boolean touchDragged(int screenX, int screenY, int pointer) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean mouseMoved(int screenX, int screenY) {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public boolean scrolled(int amount) {
    // TODO Auto-generated method stub
    return false;
  }

}




Java Source Code List

com.noobgygames.castleinvaders.ui.DragonUltiButton.java
com.noobgygames.castleinvaders.ui.ElementSwitcherButton.java
com.noobgygames.castleinvaders.ui.StoreElement.java
com.noobgygames.castleinvaders.ui.TextureElement.java
com.noobygames.castleinvaders.Assets.java
com.noobygames.castleinvaders.CastleInvaders.java
com.noobygames.castleinvaders.DynamicGameObject.java
com.noobygames.castleinvaders.GameLiving.java
com.noobygames.castleinvaders.GameObject.java
com.noobygames.castleinvaders.MainActivity.java
com.noobygames.castleinvaders.Main.java
com.noobygames.castleinvaders.Player.java
com.noobygames.castleinvaders.Projectile.java
com.noobygames.castleinvaders.Settings.java
com.noobygames.castleinvaders.WorldRenderer.java
com.noobygames.castleinvaders.World.java
com.noobygames.castleinvaders.mobs.Croco.java
com.noobygames.castleinvaders.mobs.EarthDragon.java
com.noobygames.castleinvaders.mobs.FireDragon.java
com.noobygames.castleinvaders.mobs.FireTroll.java
com.noobygames.castleinvaders.mobs.GameScreen.java
com.noobygames.castleinvaders.mobs.GreyTroll.java
com.noobygames.castleinvaders.mobs.IceDragon.java
com.noobygames.castleinvaders.mobs.IceTroll.java
com.noobygames.castleinvaders.mobs.Murloc.java
com.noobygames.castleinvaders.mobs.Orc.java
com.noobygames.castleinvaders.mobs.Skeleton.java
com.noobygames.castleinvaders.screens.GameScreen.java
com.noobygames.castleinvaders.screens.MainMenuScreen.java
com.noobygames.castleinvaders.screens.ScoreScreen.java
com.noobygames.castleinvaders.screens.SplashScreen.java
com.noobygames.castleinvaders.screens.StoreScreen.java
com.noobygames.castleinvaders.store.StoreObject.java
com.noobygames.castleinvaders.store.Store.java
com.noobygames.nerzal.castleinvaders.spells.Burning.java
com.noobygames.nerzal.castleinvaders.spells.Freeze.java
com.noobygames.nerzal.castleinvaders.spells.SpellEffect.java
com.noobygames.nerzal.castleinvaders.spells.Spells.java
com.noobygames.utils.ArrayListUtils.java
com.noobygames.utils.ObjectSelectionContainer.java
com.noobygames.utils.OverlapTester.java
com.noobygames.utils.exceptions.OutOfBoundingException.java
com.noobygames.utils.exceptions.SliderOutOfBoundingsException.java
com.noobygames.utils.ui.Button.java
com.noobygames.utils.ui.ClickableElement.java
com.noobygames.utils.ui.DropDownMenu.java
com.noobygames.utils.ui.Element.java
com.noobygames.utils.ui.RadioButton.java
com.noobygames.utils.ui.RadioGroupButton.java
com.noobygames.utils.ui.ScrollableElement.java
com.noobygames.utils.ui.SimpleElement.java
com.noobygames.utils.ui.Slider.java
com.noobygames.utils.ui.Table.java
com.noobygames.utils.ui.TextBox.java
com.noobygames.utils.ui.Text.java
com.noobygames.utils.ui.Window.java