mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added player health action view
This commit is contained in:
parent
c3aee14f23
commit
aa6fdaa2df
8 changed files with 214 additions and 44 deletions
|
|
@ -58,10 +58,12 @@ function (Parent, NotificationCenter) {
|
|||
|
||||
Player.prototype.addDamage = function(damage, enemy) {
|
||||
this.stats.health -= damage;
|
||||
|
||||
if(this.stats.health < 0) this.stats.health = 0;
|
||||
|
||||
if(this.stats.health <= 0) {
|
||||
enemy.score();
|
||||
this.kill();
|
||||
this.kill(enemy);
|
||||
} else {
|
||||
this.broadcastStats();
|
||||
}
|
||||
|
|
@ -73,11 +75,14 @@ function (Parent, NotificationCenter) {
|
|||
this.broadcastStats();
|
||||
};
|
||||
|
||||
Player.prototype.kill = function() {
|
||||
Parent.prototype.kill.call(this);
|
||||
Player.prototype.kill = function(killedByPlayer) {
|
||||
Parent.prototype.kill.call(this, killedByPlayer);
|
||||
this.stats.deaths++;
|
||||
this.broadcastStats();
|
||||
NotificationCenter.trigger("broadcastGameCommand", "playerKill", this.id);
|
||||
NotificationCenter.trigger("broadcastGameCommand", "playerKill", {
|
||||
playerId: this.id,
|
||||
killedByPlayerId: killedByPlayer.id
|
||||
});
|
||||
};
|
||||
|
||||
Player.prototype.score = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue