Android Open Source - libgdx-demo-pax-britannica Medium Enemy Production






From Project

Back to project page libgdx-demo-pax-britannica.

License

The source code is released under:

Copyright (c) 2010 Ben Abraham, Renaud B?dard, Henk Boom, Daniel Burton, Matthew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated ...

If you think the Android project libgdx-demo-pax-britannica 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 de.swagner.paxbritannica.factory;
/* w  w  w.  j  av a  2 s .  c  om*/
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Vector2;

import de.swagner.paxbritannica.GameInstance;
import de.swagner.paxbritannica.Ship;
import de.swagner.paxbritannica.bomber.Bomber;
import de.swagner.paxbritannica.fighter.Fighter;
import de.swagner.paxbritannica.frigate.Frigate;

public class MediumEnemyProduction extends FactoryProduction {

  int action_index = 0;
  float timeToHold = 0;
  float accumulated_frames = 0;
  float frames_to_wait = 0;
  int script_index = 0;
  float delta;

  int action = -1;

  int enemyFighters = 0;
  int enemyBombers = 0;
  int enemyFrigates = 0;
  int ownFighters = 0;
  int ownBombers = 0;
  int ownFrigates = 0;
  
  public MediumEnemyProduction(int id, Vector2 position, Vector2 facing) {
    super(id, position, facing);
  }

  @Override
  public void draw(Batch batch) {
    delta = Math.min(0.06f, Gdx.graphics.getDeltaTime());

    super.draw(batch);

    accumulated_frames += 30 * delta;

    if (production.currentBuildingUnit != action && action >-1) {
      button_held = true;
    } else {
      button_held = false;
      next_action();
    }

    thrust();
    turn(1);
  }

  public void next_action() {
    action = -1;    
    enemyFighters = 0;
    enemyBombers = 0;
    enemyFrigates = 0;
    ownFighters = 0;
    ownBombers = 0;
    ownFrigates = 0;        
    accumulated_frames = 0;
    timeToHold = 0;


    for (Ship fighter : GameInstance.getInstance().fighters) {
      if(fighter.id != this.id) {
        if(((Fighter) fighter).ai.target != null && ((Fighter) fighter).ai.target.id == this.id) {
          enemyFighters++;
        }
      }
      else ownFighters++;
    }
    
    for (Ship bomber : GameInstance.getInstance().bombers) {
      if(bomber.id != this.id) {
        if(((Bomber) bomber).ai.target != null && ((Bomber) bomber).ai.target.id == this.id) {
          enemyBombers++;
        }
      }
      else ownBombers++;
    }
    
    for (Ship frigate : GameInstance.getInstance().frigates) {
      if(frigate.id != this.id) {
        if(((Frigate) frigate).ai.target != null && ((Frigate) frigate).ai.target.id == this.id) {
          enemyFrigates++;
        }
      }
      else ownFrigates++;
    }
    
    // what to do
    if(resourceAmount < 80) action = -1;
    else if(ownFighters < 5) action = 0;
    else if(ownBombers < 4) action = 1;
    else if(ownFrigates < 3) action = 2;
    else action = 3;
  }

}




Java Source Code List

de.swagner.paxbritannica.Bullet.java
de.swagner.paxbritannica.Collision.java
de.swagner.paxbritannica.Constants.java
de.swagner.paxbritannica.DefaultScreen.java
de.swagner.paxbritannica.GameInstance.java
de.swagner.paxbritannica.GameScreen.java
de.swagner.paxbritannica.IOSLauncher.java
de.swagner.paxbritannica.PaxBritannica.java
de.swagner.paxbritannica.Resources.java
de.swagner.paxbritannica.Ship.java
de.swagner.paxbritannica.Targeting.java
de.swagner.paxbritannica.android.AndroidLauncher.java
de.swagner.paxbritannica.background.BackgroundFXRenderer.java
de.swagner.paxbritannica.background.Debris.java
de.swagner.paxbritannica.background.Fish.java
de.swagner.paxbritannica.bomber.Bomb.java
de.swagner.paxbritannica.bomber.BomberAI.java
de.swagner.paxbritannica.bomber.Bomber.java
de.swagner.paxbritannica.client.HtmlLauncher.java
de.swagner.paxbritannica.desktop.DesktopLauncher.java
de.swagner.paxbritannica.factory.EasyEnemyProduction.java
de.swagner.paxbritannica.factory.FactoryProduction.java
de.swagner.paxbritannica.factory.HardEnemyProduction.java
de.swagner.paxbritannica.factory.MediumEnemyProduction.java
de.swagner.paxbritannica.factory.PlayerProduction.java
de.swagner.paxbritannica.factory.Production.java
de.swagner.paxbritannica.fighter.FighterAI.java
de.swagner.paxbritannica.fighter.Fighter.java
de.swagner.paxbritannica.fighter.Laser.java
de.swagner.paxbritannica.frigate.FrigateAI.java
de.swagner.paxbritannica.frigate.Frigate.java
de.swagner.paxbritannica.frigate.MissileAI.java
de.swagner.paxbritannica.frigate.Missile.java
de.swagner.paxbritannica.help.Help.java
de.swagner.paxbritannica.mainmenu.Countdown.java
de.swagner.paxbritannica.mainmenu.FactorySelector.java
de.swagner.paxbritannica.mainmenu.MainMenu.java
de.swagner.paxbritannica.particlesystem.BigBubbleParticleEmitter.java
de.swagner.paxbritannica.particlesystem.BubbleParticleEmitter.java
de.swagner.paxbritannica.particlesystem.ExplosionParticleEmitter.java
de.swagner.paxbritannica.particlesystem.ParticleEmitter.java
de.swagner.paxbritannica.particlesystem.Particle.java
de.swagner.paxbritannica.particlesystem.SparkParticleEmitter.java
de.swagner.paxbritannica.settings.Settings.java