Android Open Source - Castle-Invaders Dynamic Game Object






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;
/*w  w  w . j a  v  a  2s  .c om*/
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

import com.noobygames.castleinvaders.World.Species;
import com.noobygames.castleinvaders.World.States;


public abstract class DynamicGameObject extends GameObject {

  protected GameLiving target;

  public States state;
  public Species species;
  public final Vector2 velocity;
  public final Vector2 accel;
  public final float width;
  private float centerX;

  protected double hitRange;

  public enum Condition {
    snare, root, dot, stun
  }

  public DynamicGameObject(float x, float y, float width, float height,
      Species species) {
    super(x, y, width, height);
    target = null;
    this.species = species;
    velocity = new Vector2();
    accel = new Vector2();
    this.width = width;
    setCenterX(x+width/2);

  }

  public DynamicGameObject(Rectangle bounds) {
    super(bounds);
    velocity = null;
    accel = null;
    width = bounds.getWidth();
  }

  /**
   * Pr?ft den Abstand zwischen Objekt & Target
   * 
   * @param obj1
   *            object
   * @param obj2
   *            target
   * @return returns true on target hit
   **/
  protected boolean rangeCheck(GameLiving obj1, GameLiving obj2) {

    if (obj1.species == Species.greyTroll
        || obj1.species == Species.iceTroll
        || obj1.species == Species.lavaTroll) {
      if (Math.pow(obj1.hitRange, 2) >= Math.pow((obj1.position.x + 20)
          - obj2.position.x, 2))
        return true;
      
    } else if (obj1.species == Species.orc) {
      if (Math.pow(obj1.hitRange, 2) >= Math.pow((obj1.position.x)
          - obj2.position.x, 2))
        return true;
    }
    
    return false;
  }

  public float getCenterX() {
    return centerX;
  }

  public void setCenterX(float centerX) {
    this.centerX = centerX;
  }
}




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