Output now shows the air-line distance of old position

This commit is contained in:
Oliver Rümpelein 2014-10-18 15:06:27 +02:00
parent c4ad471099
commit a100fca3ef
2 changed files with 28 additions and 4 deletions

View file

@ -248,10 +248,25 @@
$('#uiatt').html(outstr); $('#uiatt').html(outstr);
$('#att').bind("change", function() {cur_sel.att=this.value;}); $('#att').bind("change", function() {
cur_sel.att=this.value;
cur_sel.printoutput();
});
$('#defendible').bind("change", $('#defendible').bind("change",
function() { cur_sel.defendible = (this.value === "true" ? true : false);}); function() {
cur_sel.defendible = (this.value === "true" ? true : false);
cur_sel.printoutput();
});
$("#"+this.att).get(0).selected="true"; $("#"+this.att).get(0).selected="true";
},
calc_dist: function() {
var g = this.graphelement;
g.calc_center();
var dx = Math.abs(g.cx - g.old_pos["cx"]);
var dy = Math.abs(g.cy - g.old_pos.cy);
var distpx= Math.sqrt(dx*dx + dy*dy);
return (distpx/meters).toFixed(1);
} }
}); });
@ -323,6 +338,7 @@
outstr += this.info.cname + " (gespielt von "+this.info.pname +")<br>"; outstr += this.info.cname + " (gespielt von "+this.info.pname +")<br>";
outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von " outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von "
+ this.battle[this.att] + " an.<br>"; + this.battle[this.att] + " an.<br>";
outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)<br>";
outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>"; outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>";
outstr += "Kraftpunkte: " + this.life; outstr += "Kraftpunkte: " + this.life;
outstr += "</p>"; outstr += "</p>";
@ -348,6 +364,7 @@
outstr += "Ein "+ this.info.race + "<br>"; outstr += "Ein "+ this.info.race + "<br>";
outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von " outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von "
+ this.battle[this.att] + " an.<br>"; + this.battle[this.att] + " an.<br>";
outstr += "Ist "+this.calc_dist()+"m von der alten Position entfernt (max ??)<br>";
outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>"; outstr += "Verteidigungsstärke: " + this.battle.defense + "<br>";
outstr += "Kraftpunkte: " + this.life; outstr += "Kraftpunkte: " + this.life;
outstr += "</p>"; outstr += "</p>";

View file

@ -90,9 +90,11 @@
if(e.mouseButton === Crafty.mouseButtons.LEFT) { if(e.mouseButton === Crafty.mouseButtons.LEFT) {
if( cur_sel != player[this.id] ) { if( cur_sel != player[this.id] ) {
this.calc_center(); this.calc_center();
}; this.old_pos["cx"]=this.cx;
this.old_pos["cy"]=this.cy;
this.old_pos["x"]=this.x; this.old_pos["x"]=this.x;
this.old_pos["y"]=this.y; this.old_pos["y"]=this.y;
};
Crafty("Creature").each( function() { Crafty("Creature").each( function() {
this.disableControl(); this.disableControl();
}); });
@ -117,6 +119,11 @@
}; };
}; };
}); });
this.bind('MouseUp', function(e) {
if(e.mouseButton === Crafty.mouseButtons.LEFT) {
cur_sel.printoutput();
}
});
return this; return this;
}, },