Android Open Source - bluedroid-mp Unit






From Project

Back to project page bluedroid-mp.

License

The source code is released under:

Apache License

If you think the Android project bluedroid-mp 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 uk.ac.gcu.bluedroid.units;
/* w w w .j a  v  a 2 s.c  o  m*/
import uk.ac.gcu.bluedroid.util.Position;

public class Unit {
  
  //id generator
  private static int id_generator = 1;
  
  //instance variables
  protected int owner;
  protected int id;
  protected int power;
  protected int max_life;
  protected int life;
  protected int range;
  protected int move;
  protected String prefix;
  
  protected Position pos;
  
  public Unit(int owner, Position pos){
    this.owner = owner;
    this.pos = pos;
    this.id = id_generator++;
  }
  
  /**
   * 
   * @param newPos
   */
  public void walk(Position newPos){
    this.pos = newPos;
  }
  
  /**
   * 
   * @param enemy
   */
  public void attack(Unit enemy){
    enemy.takeDemage(this.power);
  }
  
  /**
   * 
   * @param power
   */
  public void takeDemage(int power){
    life-=power;
    if(life<=0)
      life = 0;
  }

  public int getOwner() {
    return owner;
  }

  public int getId() {
    return id;
  }

  public int getPower() {
    return power;
  }

  public int getMax_life() {
    return max_life;
  }

  public int getLife() {
    return life;
  }

  public int getRange() {
    return range;
  }

  public int getMove() {
    return move;
  }

  public String getPrefix() {
    return prefix;
  }

  public Position getPosition() {
    return pos;
  }

  public void setOwner(int owner) {
    this.owner = owner;
  }

  public void setId(int id) {
    this.id = id;
  }

  public void setPower(int power) {
    this.power = power;
  }

  public void setMax_life(int max_life) {
    this.max_life = max_life;
  }

  public void setLife(int life) {
    this.life = life;
  }

  public void setRange(int range) {
    this.range = range;
  }

  public void setMove(int move) {
    this.move = move;
  }

  public void setPrefix(String prefix) {
    this.prefix = prefix;
  }

  public void setPos(Position pos) {
    this.pos = pos;
  }
  
  
    
}




Java Source Code List

uk.ac.gcu.bluedroid.BluetoothChatService.java
uk.ac.gcu.bluedroid.DeviceListActivity.java
uk.ac.gcu.bluedroid.MainActivity.java
uk.ac.gcu.bluedroid.Wrapper.java
uk.ac.gcu.bluedroid.game.GameState.java
uk.ac.gcu.bluedroid.game.Map.java
uk.ac.gcu.bluedroid.game.Maps.java
uk.ac.gcu.bluedroid.game.Player.java
uk.ac.gcu.bluedroid.game.TurnInfo.java
uk.ac.gcu.bluedroid.resources.Camp.java
uk.ac.gcu.bluedroid.resources.Crop.java
uk.ac.gcu.bluedroid.resources.Mine.java
uk.ac.gcu.bluedroid.resources.Resource.java
uk.ac.gcu.bluedroid.units.Archer.java
uk.ac.gcu.bluedroid.units.Paladin.java
uk.ac.gcu.bluedroid.units.Soldier.java
uk.ac.gcu.bluedroid.units.Unit.java
uk.ac.gcu.bluedroid.util.CustomImageVIew.java
uk.ac.gcu.bluedroid.util.MyTextView.java
uk.ac.gcu.bluedroid.util.Node.java
uk.ac.gcu.bluedroid.util.Pathfinder.java
uk.ac.gcu.bluedroid.util.Position.java
uk.ac.gcu.bluedroid.util.Util.java