update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user