[common] update for network
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package ru.m.tankz.network;
|
||||
|
||||
import ru.m.tankz.game.IGame;
|
||||
import haxe.Unserializer;
|
||||
import haxework.signal.Signal;
|
||||
import ru.m.connect.IConnection;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.game.GameEvent;
|
||||
import ru.m.tankz.proto.core.GameProto;
|
||||
import ru.m.tankz.proto.core.UserProto;
|
||||
import ru.m.tankz.proto.game.GameChangeProto;
|
||||
@@ -41,6 +44,7 @@ class NetworkManager {
|
||||
|
||||
@:provide private var connection:ClientConnection;
|
||||
@:provide private var storage:MultiplayerStorage;
|
||||
@:provide private var _game:IGame;
|
||||
|
||||
public function new() {
|
||||
stateSignal = new Signal();
|
||||
@@ -148,6 +152,11 @@ class NetworkManager {
|
||||
} else if (packet.hasStartGame()) {
|
||||
game = packet.startGame.game;
|
||||
gameSignal.emit(game);
|
||||
} else if (packet.hasGameEvent()) {
|
||||
var frame = packet.gameEvent.frame;
|
||||
var eventStr = packet.gameEvent.event;
|
||||
var event:GameEvent = Unserializer.run(eventStr);
|
||||
_game.gameEventSignal.emit(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +224,9 @@ class Render extends SpriteView implements IRender {
|
||||
item.destroy();
|
||||
case _:
|
||||
}
|
||||
#if cpp
|
||||
flash.Lib.current.stage.invalidate();
|
||||
#end
|
||||
}
|
||||
|
||||
private function playAnimate(point:Point, animate:OnceAnimate):Promise<Dynamic> {
|
||||
|
||||
@@ -47,7 +47,8 @@ import ru.m.tankz.proto.core.UserProto;
|
||||
public function onHide():Void {
|
||||
network.gameSignal.disconnect(onGame);
|
||||
network.stateSignal.disconnect(onState);
|
||||
network.leaveGame();
|
||||
// ToDo:
|
||||
//network.leaveGame();
|
||||
}
|
||||
|
||||
private function onGame(game:GameProto):Void {
|
||||
|
||||
Reference in New Issue
Block a user