Android Open Source - diploma-assignment Statistics Menu






From Project

Back to project page diploma-assignment.

License

The source code is released under:

MIT License

If you think the Android project diploma-assignment 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.me.openingscreen;
//from  w w  w  . j  ava 2 s.c  o  m
import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.me.battlescreen.MyButton;
import com.me.battlescreen.MyLabel;

public class StatisticsMenu extends AbstractMenu{
  
  BitmapFont font2;
  MyButton toPlayerScreen;
  MyButton arrowStatisticsRight;
  MyButton arrowStatisticsLeft;
  ArrayList<Actor> statisticsFirst;
  ArrayList<Actor> statisticsSecond;
  ArrayList<MyLabel> statisticsLabels;
  

  public StatisticsMenu(OpeningScreen s, Stage st) {
    super(s, st);
    // TODO Auto-generated constructor stub
    
    font2=new BitmapFont(Gdx.files.internal("data/myFont.fnt")
        ,Gdx.files.internal("data/myFont.png"),false);
    font2.setUseIntegerPositions(false);
    font2.setScale(screen.getHeight()*0.15f/font2.getLineHeight());
    
    statisticsFirst=new ArrayList<Actor>();
    statisticsSecond=new ArrayList<Actor>();
    statisticsLabels=new ArrayList<MyLabel>();
    
    createButtons();
    
    addListeners();
    
    showArrayList(statisticsFirst);
  }
  
  @Override
  protected void createButtons(){
    Texture t=new Texture(Gdx.files.internal("data/menus/left.png"));
    arrowStatisticsLeft=new MyButton(t);
    createButton(arrowStatisticsLeft,1,t,2);
    arrowStatisticsLeft.setPosition(0, arrowStatisticsLeft.getY());
    
    t=new Texture(Gdx.files.internal("data/menus/right.png"));
    arrowStatisticsRight=new MyButton(t);
    createButton(arrowStatisticsRight,1,t,2);
    arrowStatisticsRight.setPosition(screen.getWidth()-
        arrowStatisticsRight.getWidth(),arrowStatisticsRight.getY());
    
    t=new Texture(Gdx.files.internal("data/menus/player.png"));
    toPlayerScreen=new MyButton(t);
    createButton(toPlayerScreen,1,t,1);
    
    createStatisticsImages();
  }
  
  @Override
  protected void addListeners(){
    toPlayerScreen.addListener(new InputListener(){
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        toPlayerScreen.setPressed(true);
                return true;
      }
        
      public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        toPlayerScreen.setPressed(false);
        screen.setMenu(new PlayerMenu(screen,stage));
          }
    });
    
    arrowStatisticsLeft.addListener(new InputListener(){
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        arrowStatisticsLeft.setPressed(true);
                return true;
      }
        
      public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        arrowStatisticsLeft.setPressed(false);
        showArrayList(statisticsFirst);
          }
    });
    
    arrowStatisticsRight.addListener(new InputListener(){
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        arrowStatisticsRight.setPressed(true);
                return true;
      }
        
      public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        arrowStatisticsRight.setPressed(false);
        showArrayList(statisticsSecond);
          }
    });
    
    statisticsFirst.add(arrowStatisticsRight);
    statisticsSecond.add(arrowStatisticsLeft);
  }
  
  private void createStatisticsImages() {
    // TODO Auto-generated method stub
    int heightButton=(int)(screen.getHeight()*0.2f);
    int height_offset=(int)(screen.getHeight()*0.6f);
    int width_offset=(int)(screen.getHeight()*0.1f);
    
    Texture[] textures=new Texture[]{new Texture(Gdx.files.internal("data/thumbnails/skeleton_t.png")),new Texture(Gdx.files.internal("data/thumbnails/zombie_t.png")),new Texture(Gdx.files.internal("data/thumbnails/wigth_t.png")),new Texture(Gdx.files.internal("data/thumbnails/vampire_t.png")),new Texture(Gdx.files.internal("data/thumbnails/lich_t.png")),new Texture(Gdx.files.internal("data/thumbnails/blackKnight_t.png")),new Texture(Gdx.files.internal("data/thumbnails/boneDragon_t.png"))};
    
    for (int i = 0; i < 7; i++) {
      MyLabel l=new MyLabel(screen,screen.game.getPlayer().getKilled()[i]
          +"",font2,new int[]{width_offset+2*heightButton,
        height_offset+heightButton});
      final MyButton but=new MyButton(textures[i]);
      but.setPosition(width_offset, height_offset);
      but.setSize(heightButton, heightButton);
      but.setTouchable(Touchable.disabled);
      if(i<4){
        statisticsFirst.add(but);
        statisticsFirst.add(l);
      } else{
        statisticsSecond.add(but);
        statisticsSecond.add(l);
      }
      stage.addActor(but);
      stage.addActor(l);
      statisticsLabels.add(l);
      height_offset-=(int)(screen.getHeight()*0.3f);
      if(i%2==1){
        width_offset+=(int)(screen.getWidth()*0.5f);
        height_offset=(int)(screen.getHeight()*0.6f);
      }
      if(i==3){
        height_offset=(int)(screen.getHeight()*0.6f);
        width_offset=(int)(screen.getHeight()*0.1f);
      }
    }
  }
  
  private void showArrayList(ArrayList<Actor> upgradeList) {
    // TODO Auto-generated method stub
    stage.clear();
    stage.addActor(screen.getBackground());
    stage.addActor(toPlayerScreen);
    for(Actor act:upgradeList){
      stage.addActor(act);
    }
  }

}




Java Source Code List

com.me.battlescreen.BallistaArrow.java
com.me.battlescreen.Ballista.java
com.me.battlescreen.BattlePlayer.java
com.me.battlescreen.BattleScreen.java
com.me.battlescreen.Bot.java
com.me.battlescreen.Castle.java
com.me.battlescreen.CleanBackground.java
com.me.battlescreen.ComputerPlayer.java
com.me.battlescreen.Constants.java
com.me.battlescreen.HumanPlayer.java
com.me.battlescreen.Monster.java
com.me.battlescreen.MyButton.java
com.me.battlescreen.MyLabel.java
com.me.battlescreen.OpponentMonster.java
com.me.battlescreen.PlayerMonster.java
com.me.battlescreen.TimeLabel.java
com.me.battlescreen.UnitButton.java
com.me.battlescreen.getTextures.java
com.me.battlescreen.iAttacking.java
com.me.battlescreen.iHittable.java
com.me.battlescreen.iUpdateable.java
com.me.main.MyGame.java
com.me.main.Player.java
com.me.mygdxgame.MainActivity.java
com.me.openingscreen.AbstractMenu.java
com.me.openingscreen.Constants.java
com.me.openingscreen.FirstMenu.java
com.me.openingscreen.FloatingBackground.java
com.me.openingscreen.OpeningScreen.java
com.me.openingscreen.PlayerMenu.java
com.me.openingscreen.ResetMenu.java
com.me.openingscreen.StatisticsMenu.java
com.me.openingscreen.UpgradeButton.java
com.me.openingscreen.UpgradeMenu.java