Back to project page Station42.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...
If you think the Android project Station42 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.station42.death; /*from www . ja va2 s. c o m*/ import com.station42.base.Engine; public class Health { private int maxHealth; private int currentHealth; public Health(int maxHealth) { this.maxHealth = maxHealth; this.currentHealth = maxHealth; } public int getHealth() { return currentHealth; } public int getMaxHealth() { return maxHealth; } public boolean damage(Engine engine, int i) { if (currentHealth <= 0) return false; currentHealth -= i; return currentHealth <= 0; } public boolean heal(int i) { if (currentHealth > maxHealth) return false; currentHealth += i; if (currentHealth > maxHealth) { currentHealth = maxHealth; } return currentHealth >= maxHealth; } public void boost(int i) { currentHealth += i; } }