Android Open Source - Airplanes Airplanes






From Project

Back to project page Airplanes.

License

The source code is released under:

GNU General Public License

If you think the Android project Airplanes 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.axnsan.airplanes;
//www . j  av a 2 s .com
import java.util.ArrayList;
import java.util.Stack;

import com.axnsan.airplanes.screens.MainMenuScreen;
import com.axnsan.airplanes.util.ActionManager;
import com.axnsan.airplanes.util.ActionResolver;
import com.axnsan.airplanes.util.FontManager;
import com.axnsan.airplanes.util.FontManagerInterface;
import com.axnsan.airplanes.util.RandomizedQueue;
import com.axnsan.airplanes.util.StringManager;
import com.axnsan.airplanes.util.StringXmlParser;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox.CheckBoxStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldStyle;

public class Airplanes extends Game implements InputProcessor {
  public static Airplanes game;
  public static int TIMEOUT = 10;
  public static Application application;

  public static String[] colors = {"302055", "bf0808" , "e3c100",  "455520", };
  public static final int minPadding = 5, gridBorderWidth = 1;
  public static final double MAX_FPS = 30.0, MAX_FRAME_TIME = 1000/MAX_FPS;
  
  public ArrayList<Player> players;
  public InputMultiplexer input = new InputMultiplexer();
  public Skin skin;
  
  private Screen mainMenuScreen;
  private Stack<Screen> history = new Stack<Screen>();
  private TextButton dummyTextButton;
  private CheckBox dummyCheckBox;
  private Label dummyLabel;
  private TextField dummyTextField;
  
  public GameConfiguration config;
  public GameState state;
  
  public Airplanes(FontManagerInterface fontEngine, StringXmlParser xmlParser, ActionResolver action) {
    FontManager.initialize(fontEngine);
    StringManager.initialize(xmlParser);
    ActionManager.initialize(action);
  }
  
  public void setTextButtonFont(BitmapFont font) {
    TextButtonStyle tbs = skin.get(TextButtonStyle.class);
    tbs.font = font;
    dummyTextButton.setStyle(tbs);
  }
  
  public void setCheckBoxFont(BitmapFont font) {
    CheckBoxStyle cbs = skin.get(CheckBoxStyle.class);
    cbs.font = font;
    cbs.fontColor = Color.GRAY;
    dummyCheckBox.setStyle(cbs);
  }
  
  public void setLabelFont(BitmapFont font) {
    LabelStyle ls = skin.get(LabelStyle.class);
    ls.font = font;
    ls.fontColor = Color.GRAY;
    dummyLabel.setStyle(ls);
  }
  
  public void setTextFieldFont(BitmapFont font) {
    TextFieldStyle tfs = skin.get(TextFieldStyle.class);
    tfs.font = font;
    tfs.fontColor = Color.WHITE;
    dummyTextField.setStyle(tfs);
  }
  
  @Override
  public void create() {
    game = this;
    Gdx.input.setInputProcessor(input);
    Gdx.input.setCatchBackKey(true);
    Gdx.graphics.setContinuousRendering(false);
    //StringManager.setLocale("ro_RO");
    input.addProcessor(this);
    skin = new Skin(Gdx.files.internal("data/ui/uiskin.json"));
    dummyTextButton = new TextButton("", skin);
    setTextButtonFont(FontManager.getFontForHeight(20));
    dummyCheckBox = new CheckBox("", skin);
    setCheckBoxFont(FontManager.getFontForHeight(20));
    dummyLabel = new Label("", skin);
    setLabelFont(FontManager.getFontForHeight(20));
    dummyTextField = new TextField("", skin);
    setTextFieldFont(FontManager.getFontForHeight(20));

    mainMenuScreen = new MainMenuScreen();
    super.setScreen(mainMenuScreen);
  }
  
  public void back() {
    if (!history.empty()) {
      history.pop().dispose();
      if (!history.empty())
        super.setScreen(history.peek());
      else super.setScreen(mainMenuScreen);
    }
    System.gc();
  }
  
  public void resetToMainMenu() {
    super.setScreen(null);
    while (!history.empty())
      history.pop().dispose();
    super.setScreen(mainMenuScreen);
  }
  
  public int maxNumPlanes() {
    return Plane.maxPlanesOnGridSize(config.gridSize);
  }
  
  public int maxNumPlanes(int gridSize) {
    return Plane.maxPlanesOnGridSize(gridSize);
  }
  
  public int minGridSize() {
    Plane.Model model = Plane.templateModel();
    
    return Math.max(model.width, model.height);
  }
  
  public int maxGridSize() {
    
    return 50;
  }
  
  @Override 
  public void setScreen(Screen screen)
  {
    history.push(screen);
    super.setScreen(screen);
    System.gc();
  }
  
  @Override
  public void dispose() {
    super.setScreen(null);
    while (!history.empty())
      history.pop().dispose();
    mainMenuScreen.dispose();
    if (players != null)
      for (Player p: players)
        p.dispose();
    skin.dispose();
    FontManager.dispose();
  }

  public void exit() {
    dispose();
    Gdx.app.exit();
  }
  
  public static RandomizedQueue<String> colorsRandom = new RandomizedQueue<String>();
  public static ArrayList<String> colorsList = new ArrayList<String>();
  static {
    for (String s : colors)
    {
      colorsRandom.push(s);
      colorsList.add(s);
    }
  }
  
  @Override
  public boolean keyDown(int keycode) {
    switch (keycode) {
    case Keys.BACK:
      back();
      return true;
    }
    return false;
  }
  
  @Override
  public boolean keyUp(int keycode) {
    return false;
  }

  @Override
  public boolean keyTyped(char character) {
    return false;
  }

  @Override
  public boolean touchDown(int screenX, int screenY, int pointer, int button) {
    return false;
  }

  @Override
  public boolean touchUp(int screenX, int screenY, int pointer, int button) {
    return false;
  }

  @Override
  public boolean touchDragged(int screenX, int screenY, int pointer) {
    return false;
  }

  @Override
  public boolean mouseMoved(int screenX, int screenY) {
    return false;
  }

  @Override
  public boolean scrolled(int amount) {
    return false;
  }
}




Java Source Code List

com.axnsan.airplanes.Airplanes.java
com.axnsan.airplanes.BaseGrid.java
com.axnsan.airplanes.GameConfiguration.java
com.axnsan.airplanes.GameState.java
com.axnsan.airplanes.GridRandomizer.java
com.axnsan.airplanes.Grid.java
com.axnsan.airplanes.GuardedScreen.java
com.axnsan.airplanes.HotseatMatchHandler.java
com.axnsan.airplanes.MainActivity.java
com.axnsan.airplanes.Main.java
com.axnsan.airplanes.MatchHandler.java
com.axnsan.airplanes.PlacementGrid.java
com.axnsan.airplanes.Plane.java
com.axnsan.airplanes.Player.java
com.axnsan.airplanes.PlayingGrid.java
com.axnsan.airplanes.online.ClientSocket.java
com.axnsan.airplanes.online.EventHandler.java
com.axnsan.airplanes.online.Game.java
com.axnsan.airplanes.online.LobbyScreen.java
com.axnsan.airplanes.online.LoginScreen.java
com.axnsan.airplanes.online.Message.java
com.axnsan.airplanes.online.Messages.java
com.axnsan.airplanes.online.OnlineGameScreen.java
com.axnsan.airplanes.online.OnlineMatchHandler.java
com.axnsan.airplanes.online.OnlineMenuScreen.java
com.axnsan.airplanes.online.OnlineSettingsScreen.java
com.axnsan.airplanes.online.SessionData.java
com.axnsan.airplanes.screens.BeginTurnScreen.java
com.axnsan.airplanes.screens.HotseatPlayersScreen.java
com.axnsan.airplanes.screens.HotseatScreen.java
com.axnsan.airplanes.screens.HotseatSettingsScreen.java
com.axnsan.airplanes.screens.HotseatStartScreen.java
com.axnsan.airplanes.screens.MainMenuScreen.java
com.axnsan.airplanes.screens.PlacementScreen.java
com.axnsan.airplanes.screens.PlayMenuScreen.java
com.axnsan.airplanes.screens.PracticeScreen.java
com.axnsan.airplanes.screens.PracticeSettingsScreen.java
com.axnsan.airplanes.screens.PracticeStartScreen.java
com.axnsan.airplanes.util.ActionManager.java
com.axnsan.airplanes.util.ActionResolver.java
com.axnsan.airplanes.util.BasicFontManager.java
com.axnsan.airplanes.util.Detector.java
com.axnsan.airplanes.util.DoubleTapDetector.java
com.axnsan.airplanes.util.DoubleTapListener.java
com.axnsan.airplanes.util.FontManagerInterface.java
com.axnsan.airplanes.util.FontManager.java
com.axnsan.airplanes.util.JavaXmlParser.java
com.axnsan.airplanes.util.Point2D.java
com.axnsan.airplanes.util.RandomizedQueue.java
com.axnsan.airplanes.util.StringManager.java
com.axnsan.airplanes.util.StringXmlParser.java
com.axnsan.airplanes.util.TTFFontManager.java
com.axnsan.airplanes.util.TapDetector.java
com.axnsan.airplanes.util.TapListener.java