Browse Source

added packet repeat property

Erinn 8 years ago
parent
commit
7849c54a15
2 changed files with 11 additions and 1 deletions
  1. 8 1
      js/bindings.js
  2. 3 0
      js/ui.js

+ 8 - 1
js/bindings.js

@@ -76,6 +76,13 @@ function btnEdit() {
 
 function btnLaunch() {
 	var pkt = playerPackets[this.launcherIndex];
-	doPacketAnimation(pkt.from, getDefaultRecipient(pkt.from), pkt.payload);
+
+	if (pkt.hasOwnProperty("repeat") && pkt.repeat > 1) {
+		for (var i = 0; i < pkt.repeat; i++) {
+			game.time.events.add( 100 * i, playPacket, pkt );
+		}
+	} else {
+		doPacketAnimation(pkt.from, getDefaultRecipient(pkt.from), pkt.payload);
+	}
 }
 

+ 3 - 0
js/ui.js

@@ -58,6 +58,8 @@ function createPacketEditor(index, packet) {
 		str += "</fieldset>";
 	}
 
+	str += "<p>Repeat: <input type=\"text\" id=\"repeat\" style=\"width:40px;\" value=\""+(packet.hasOwnProperty("repeat") ? packet.repeat : 1)+"\"></p>";
+
 	$("#editor").html(str);
 	$('#editor').dialog({
 		title: index < 0 ? "Add packet" : "Update packet",
@@ -71,6 +73,7 @@ function createPacketEditor(index, packet) {
 function updatePlayerPacket(index) {
 	playerPackets[index] = {
 		from: $("#pktFrom").val(),
+		repeat: $("#repeat").val(),
 		payload:{}
 	};