This commit is contained in:
2015-08-12 17:54:00 +03:00
parent 3eee4db51b
commit a37712136e
5 changed files with 96 additions and 28 deletions

View File

@@ -73,13 +73,29 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
break;
}
}
case GameObjectType.BULLET:
for (tank in engine.tanks) {
if (tank.id == change.parentObjectId) {
for (bullet in tank.bullets) {
if (bullet.id == change.objectId) {
bullet.x = change.x;
bullet.y = change.y;
break;
}
}
break;
}
}
}
case GameChangeType.APPEND:
switch (change.objectType) {
case GameObjectType.BULLET:
for (tank in engine.tanks) {
if (tank.id == change.parentObjectId) {
tank.bullets.push(new MobileEntity(0, change.x, change.y, 0, new Direction(change.directionX, change.directionY)));
var bullet = new MobileEntity(change.objectId, change.x, change.y, 0, new Direction(change.directionX, change.directionY));
bullet.width = 10;
bullet.height = 10;
tank.bullets.push(bullet);
break;
}
}

View File

@@ -1,5 +1,7 @@
package ru.m.tankz.view.frames;
import ru.m.tankz.proto.LeaveGameResponse;
import ru.m.tankz.proto.JoinGameResponse;
import haxework.gui.ViewBuilder;
import ru.m.tankz.proto.ExitGameResponse;
import haxework.gui.frame.IFrameSwitcher;
@@ -43,7 +45,18 @@ class GameReadyFrame extends VGroupView implements ViewBuilder implements IPacke
Provider.get(IFrameSwitcher).change(GameFrame.ID);
}
public function onJoinGameResponse(packet:JoinGameResponse):Void {
Provider.get(GameData).game = packet.game;
list.data = Provider.get(GameData).game.persons;
}
public function onLeaveGameResponse(packet:LeaveGameResponse):Void {
Provider.get(GameData).game = packet.game;
list.data = Provider.get(GameData).game.persons;
}
public function onExitGameResponse(packet:ExitGameResponse):Void {
Provider.get(GameData).game = null;
Provider.get(IFrameSwitcher).change(GameListFrame.ID);
}