This commit is contained in:
2015-08-12 15:19:34 +03:00
parent 64e1cfdbfc
commit 64d36c6924
14 changed files with 314 additions and 30 deletions

View File

@@ -49,7 +49,11 @@ class PlayerTank extends Tank {
private function updateMove():Void {
if (moveQueue.length == 0) {
stop();
//stop();
Provider.get(IConnection).send(
new GameActionRequest()
.setType(GameActionType.STOP)
);
} else {
switch (keyBinding.get(moveQueue[0])) {
case TankAction.MOVE(direction):

View File

@@ -1,5 +1,9 @@
package ru.m.tankz.view.frames;
import ru.m.tankz.core.MobileEntity;
import ru.m.tankz.core.Direction;
import ru.m.tankz.proto.GameObjectType;
import ru.m.tankz.proto.GameChangeType;
import ru.m.tankz.game.ClientTankz;
import protohx.Message;
import ru.m.tankz.proto.GameUpdateResponse;
@@ -32,6 +36,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
game.init(persons, DEFAULT.CONFIG);
content.addEventListener(Event.ENTER_FRAME, updateGame);
Provider.get(IConnection).packetHandler.addListener(this);
render.draw(game);
}
public function onHide():Void {
@@ -41,12 +46,47 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
}
private function updateGame(_):Void {
game.update();
render.draw(game);
//game.update();
//render.draw(game);
}
public function onGameUpdateResponse(packet:GameUpdateResponse):Void {
for (change in packet.changes) {
switch (change.type) {
case GameChangeType.DIRECTION:
switch (change.objectType) {
case GameObjectType.TANK:
for (tank in game.tanks) {
if (tank.id == change.objectId) {
tank.direction = new Direction(change.directionX, change.directionY);
break;
}
}
}
case GameChangeType.MOVED:
switch (change.objectType) {
case GameObjectType.TANK:
for (tank in game.tanks) {
if (tank.id == change.objectId) {
tank.x = change.x;
tank.y = change.y;
break;
}
}
}
case GameChangeType.APPEND:
switch (change.objectType) {
case GameObjectType.BULLET:
for (tank in game.tanks) {
if (tank.id == change.parentObjectId) {
tank.bullets.push(new MobileEntity(0, change.x, change.y, 0, new Direction(change.directionX, change.directionY)));
break;
}
}
}
}
}
render.draw(game);
}
public function onPacket(packet:Message):Void {}