Android Open Source - Apocalypse-Defense Person






From Project

Back to project page Apocalypse-Defense.

License

The source code is released under:

MIT License

If you think the Android project Apocalypse-Defense 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.apocalypsedefense.core;
//  w w  w .  j  av a 2s .c  o  m
public class Person extends MapElement {
  public int hp;
  public boolean isAlive;
  public Weapon weapon;
  private int previousHealth;

  public Person(Weapon weapon, int hp, int size, Point position) {
    super(size,position);
    this.hp = hp;
    this.isAlive = true;
    this.weapon = weapon;
    previousHealth = hp;
  }
  
  
  public void takeDamage(int damage) {
    this.hp = this.hp - damage;
    if (this.hp <= 0){ //If the actor died
      this.isAlive = false;
    }
  }
  
  public int attack() {
      return 0;
  }
  
  public void getStats(){
    System.out.print("HP:" + this.hp);
    System.out.print("Position:" + this.position);
  }

  private static final int ATTACK_COUNTER_START = 5; // How many frames to indicate being attacked
  private int wasAttackedCounter=0;
  public boolean isBeingAttacked() {
    if (wasAttackedCounter > 0) {
      wasAttackedCounter--;
      return true;
    }
    if (hp < previousHealth) {
      wasAttackedCounter = ATTACK_COUNTER_START;
      previousHealth = hp;
      return true;
    }
    return false;
  }

}

/*
Python code:
 
class Person(MapElement):
    def __init__(self, weapon, hp=100, size=(1,1), position=(0,0)):
        MapElement.__init__(self, size, position)
        self.hp = hp
        self.isAlive = True
        self.weapon = weapon

    def takeDamage(self, damage):
        self.hp = self.hp - damage
        if self.hp <= 0: #If the actor died
            self.isAlive = False

    def attack(self):
        pass

    def getStats(self):
        print 'HP: ' + str(self.hp)
        print 'Position: ' + str(self.position)

*/




Java Source Code List

com.apocalypsedefense.app.AchievementsActivity.java
com.apocalypsedefense.app.ApocalypseDefenseActivity.java
com.apocalypsedefense.app.EndOfGameDialog.java
com.apocalypsedefense.app.ExitConfirmationDialog.java
com.apocalypsedefense.app.InGameActivity.java
com.apocalypsedefense.app.InstructionsDialog.java
com.apocalypsedefense.app.NewGameSettingsActivity.java
com.apocalypsedefense.app.OverwriteExistingGameDialog.java
com.apocalypsedefense.app.gameplay_visuals.AndroidLogAdapter.java
com.apocalypsedefense.app.gameplay_visuals.GameFacade.java
com.apocalypsedefense.app.gameplay_visuals.GameObject.java
com.apocalypsedefense.app.gameplay_visuals.GameSurfaceView.java
com.apocalypsedefense.app.gameplay_visuals.GameThread.java
com.apocalypsedefense.app.gameplay_visuals.OnGameEndListener.java
com.apocalypsedefense.app.gameplay_visuals.OnStatsChangedListener.java
com.apocalypsedefense.app.gameplay_visuals.Sprite.java
com.apocalypsedefense.core.ActorType.java
com.apocalypsedefense.core.Armor.java
com.apocalypsedefense.core.GameData.java
com.apocalypsedefense.core.GameState.java
com.apocalypsedefense.core.Game.java
com.apocalypsedefense.core.Gun.java
com.apocalypsedefense.core.LogAdapter.java
com.apocalypsedefense.core.MapElement.java
com.apocalypsedefense.core.Map.java
com.apocalypsedefense.core.Movement.java
com.apocalypsedefense.core.Person.java
com.apocalypsedefense.core.Point.java
com.apocalypsedefense.core.PrintLogAdapter.java
com.apocalypsedefense.core.Shared.java
com.apocalypsedefense.core.SurvivorManager.java
com.apocalypsedefense.core.Survivor.java
com.apocalypsedefense.core.Weapon.java
com.apocalypsedefense.core.ZombieManager.java
com.apocalypsedefense.core.Zombie.java
com.apocalypsedefense.core.testDriver.java