[proto] update message names
This commit is contained in:
@@ -10,9 +10,6 @@ import ru.m.tankz.bundle.ILevelBundle;
|
||||
import ru.m.tankz.bundle.LevelBundle;
|
||||
import ru.m.tankz.control.ClientControlFactory;
|
||||
import ru.m.tankz.control.IControlFactory;
|
||||
import ru.m.tankz.game.ClassicGame;
|
||||
import ru.m.tankz.game.DotaGame;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.network.NetworkManager;
|
||||
import ru.m.tankz.proto.pack.Request;
|
||||
import ru.m.tankz.proto.pack.Response;
|
||||
@@ -53,8 +50,6 @@ class Init {
|
||||
Provider.setFactory(SoundManager, SoundManager);
|
||||
Provider.setFactory(NetworkManager, NetworkManager);
|
||||
Provider.setFactory(IControlFactory, ClientControlFactory);
|
||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||
Provider.setFactory(Game, DotaGame, DotaGame.TYPE);
|
||||
|
||||
var host:String = getHost();
|
||||
L.d('Init', 'host: ${host}');
|
||||
|
||||
@@ -35,7 +35,7 @@ class GameFrame extends VGroupView {
|
||||
}
|
||||
|
||||
private function start(save:GameSave):Void {
|
||||
game = Provider.build(Game, save.state.type);
|
||||
game = new Game(save.state.type);
|
||||
if (game == null) {
|
||||
throw 'Unsupported game type "${save.state.type}"';
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package ru.m.tankz.frame;
|
||||
|
||||
import ru.m.tankz.game.ClassicGame;
|
||||
import ru.m.tankz.game.GameSave;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.proto.core.GameState;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.frame.IFrameSwitcher;
|
||||
import haxework.gui.IGroupView;
|
||||
@@ -11,9 +7,13 @@ import haxework.gui.InputView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.VGroupView;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.game.GameSave;
|
||||
import ru.m.tankz.network.NetworkManager;
|
||||
import ru.m.tankz.proto.core.Game;
|
||||
import ru.m.tankz.proto.core.User;
|
||||
import ru.m.tankz.preset.ClassicGame;
|
||||
import ru.m.tankz.proto.core.GameInfoProto;
|
||||
import ru.m.tankz.proto.core.GameStateProto;
|
||||
import ru.m.tankz.proto.core.UserProto;
|
||||
|
||||
|
||||
@:template("ru/m/tankz/frame/NetworkFrame.yaml", "ru/m/tankz/Style.yaml")
|
||||
@@ -29,12 +29,12 @@ class NetworkFrame extends VGroupView {
|
||||
|
||||
@:view var gameListFrame(default, null):IGroupView;
|
||||
@:view var createGameButton(default, null):ButtonView;
|
||||
@:view var gameList(default, null):ListView<Game>;
|
||||
@:view var gameList(default, null):ListView<GameInfoProto>;
|
||||
|
||||
@:view var gameFrame(default, null):IGroupView;
|
||||
@:view var leaveGameButton(default, null):ButtonView;
|
||||
@:view var startGameButton(default, null):ButtonView;
|
||||
@:view var userList(default, null):ListView<User>;
|
||||
@:view var userList(default, null):ListView<UserProto>;
|
||||
|
||||
@:provide var network:NetworkManager;
|
||||
@:provide var mainFrameSwitcher:IFrameSwitcher;
|
||||
@@ -45,7 +45,7 @@ class NetworkFrame extends VGroupView {
|
||||
leaveGameButton.onPress = this;
|
||||
startGameButton.onPress = this;
|
||||
gameList.dispatcher.addListener({
|
||||
onListItemClick: function(item:IListItemView<Game>):Void {
|
||||
onListItemClick: function(item:IListItemView<GameInfoProto>):Void {
|
||||
network.joinGame(item.data.id);
|
||||
}
|
||||
});
|
||||
@@ -71,15 +71,15 @@ class NetworkFrame extends VGroupView {
|
||||
}
|
||||
}
|
||||
|
||||
private function onListGame(games:Array<Game>):Void {
|
||||
private function onListGame(games:Array<GameInfoProto>):Void {
|
||||
gameList.data = games;
|
||||
}
|
||||
|
||||
private function onGame(game:Game):Void {
|
||||
private function onGame(game:GameInfoProto):Void {
|
||||
if (game != null) {
|
||||
userList.data = game.players;
|
||||
frameSwitcher.change(gameFrame.id);
|
||||
if (game.state == GameState.STARTED) {
|
||||
if (game.state == GameStateProto.STARTED) {
|
||||
Provider.set(GameSave, new GameSave({type: ClassicGame.TYPE, presetId: ClassicGame.PLAYER1}));
|
||||
mainFrameSwitcher.change(GameFrame.ID);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ views:
|
||||
$style: button
|
||||
text: Create
|
||||
- id: gameList
|
||||
$type: haxework.gui.list.VListView<ru.m.tankz.proto.core.Game>
|
||||
$type: haxework.gui.list.VListView<ru.m.tankz.proto.core.GameInfoProto>
|
||||
factory: "@class:ru.m.tankz.frame.network.GameItemView"
|
||||
pWidth: 100
|
||||
pHeight: 100
|
||||
@@ -73,7 +73,7 @@ views:
|
||||
$style: button
|
||||
text: Leave
|
||||
- id: userList
|
||||
$type: haxework.gui.list.VListView<ru.m.tankz.proto.core.User>
|
||||
$type: haxework.gui.list.VListView<ru.m.tankz.proto.core.UserProto>
|
||||
factory: "@class:ru.m.tankz.frame.network.UserItemView"
|
||||
pWidth: 100
|
||||
pHeight: 100
|
||||
|
||||
@@ -4,8 +4,8 @@ import haxework.gui.ButtonView;
|
||||
import haxework.gui.frame.IFrameSwitcher;
|
||||
import haxework.gui.VGroupView;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.game.ClassicGame;
|
||||
import ru.m.tankz.game.DotaGame;
|
||||
import ru.m.tankz.preset.ClassicGame;
|
||||
import ru.m.tankz.preset.DotaGame;
|
||||
import ru.m.tankz.game.GameSave;
|
||||
import ru.m.tankz.storage.SaveStorage;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
@@ -3,18 +3,18 @@ package ru.m.tankz.frame.network;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import ru.m.tankz.proto.core.Game;
|
||||
import ru.m.tankz.proto.core.GameInfoProto;
|
||||
|
||||
|
||||
@:template("ru/m/tankz/frame/network/GameItemView.yaml", "ru/m/tankz/Style.yaml")
|
||||
class GameItemView extends HGroupView implements IListItemView<Game> {
|
||||
class GameItemView extends HGroupView implements IListItemView<GameInfoProto> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Game;
|
||||
public var data(default, set):GameInfoProto;
|
||||
|
||||
@:view var label(default, null):LabelView;
|
||||
|
||||
private function set_data(value:Game):Game {
|
||||
private function set_data(value:GameInfoProto):GameInfoProto {
|
||||
data = value;
|
||||
label.text = '${data.type}';
|
||||
return data;
|
||||
|
||||
@@ -3,18 +3,18 @@ package ru.m.tankz.frame.network;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import ru.m.tankz.proto.core.User;
|
||||
import ru.m.tankz.proto.core.UserProto;
|
||||
|
||||
|
||||
@:template("ru/m/tankz/frame/network/UserItemView.yaml", "ru/m/tankz/Style.yaml")
|
||||
class UserItemView extends HGroupView implements IListItemView<User> {
|
||||
class UserItemView extends HGroupView implements IListItemView<UserProto> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):User;
|
||||
public var data(default, set):UserProto;
|
||||
|
||||
@:view var label(default, null):LabelView;
|
||||
|
||||
private function set_data(value:User):User {
|
||||
private function set_data(value:UserProto):UserProto {
|
||||
data = value;
|
||||
label.text = '${data.uuid} -- ${data.name}';
|
||||
return data;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.m.tankz.network;
|
||||
|
||||
import ru.m.tankz.proto.pack.StartGameRequest;
|
||||
import ru.m.tankz.proto.game.GameChange;
|
||||
import ru.m.tankz.proto.game.GameActionType;
|
||||
import ru.m.tankz.proto.game.GameChangeProto;
|
||||
import ru.m.tankz.proto.game.GameActionTypeProto;
|
||||
import ru.m.tankz.proto.pack.GameUpdateRequest;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.proto.pack.JoinGameRequest;
|
||||
@@ -10,7 +10,7 @@ import ru.m.tankz.proto.pack.LeaveGameRequest;
|
||||
import ru.m.tankz.proto.pack.CreateGameRequest;
|
||||
import ru.m.connect.IConnection;
|
||||
import ru.m.signal.Signal;
|
||||
import ru.m.tankz.proto.core.Game;
|
||||
import ru.m.tankz.proto.core.GameInfoProto;
|
||||
import ru.m.tankz.proto.pack.ListGameRequest;
|
||||
import ru.m.tankz.proto.pack.LoginRequest;
|
||||
import ru.m.tankz.proto.pack.Request;
|
||||
@@ -24,9 +24,9 @@ class NetworkManager {
|
||||
|
||||
public var state(default, null):String;
|
||||
public var stateSignal:Signal<String>;
|
||||
public var listGameSignal:Signal<Array<Game>>;
|
||||
public var gameSignal:Signal<Game>;
|
||||
public var gameUpdateSignal:Signal<Array<GameChange>>;
|
||||
public var listGameSignal:Signal<Array<GameInfoProto>>;
|
||||
public var gameSignal:Signal<GameInfoProto>;
|
||||
public var gameUpdateSignal:Signal<Array<GameChangeProto>>;
|
||||
public var user(default, null):User;
|
||||
|
||||
@:provide private var connection:ClientConnection;
|
||||
@@ -34,9 +34,9 @@ class NetworkManager {
|
||||
|
||||
public function new() {
|
||||
stateSignal = new Signal<String>();
|
||||
listGameSignal = new Signal<Array<Game>>();
|
||||
gameSignal = new Signal<Game>();
|
||||
gameUpdateSignal = new Signal<Array<GameChange>>();
|
||||
listGameSignal = new Signal<Array<GameInfoProto>>();
|
||||
gameSignal = new Signal<GameInfoProto>();
|
||||
gameUpdateSignal = new Signal<Array<GameChangeProto>>();
|
||||
updateState('offline');
|
||||
connection.handler.connect(onConnectionEvent);
|
||||
connection.receiveHandler.connect(onResponse);
|
||||
@@ -58,8 +58,8 @@ class NetworkManager {
|
||||
updateState('login...');
|
||||
c.send(new Request().setLogin(
|
||||
new LoginRequest()
|
||||
.setUuid(user.uuid)
|
||||
.setName(user.name)
|
||||
.setUuid(user.uuid)
|
||||
.setName(user.name)
|
||||
));
|
||||
}).catchError(function(_) {});
|
||||
}
|
||||
@@ -86,9 +86,17 @@ class NetworkManager {
|
||||
|
||||
public function action(action:TankAction):Void {
|
||||
var update:GameUpdateRequest = switch action {
|
||||
case TankAction.MOVE(direction): new GameUpdateRequest().setType(GameActionType.MOVE).setDirectionX(direction.x).setDirectionY(direction.y);
|
||||
case TankAction.STOP: new GameUpdateRequest().setType(GameActionType.STOP);
|
||||
case TankAction.SHOT: new GameUpdateRequest().setType(GameActionType.SHOT);
|
||||
case TankAction.MOVE(direction):
|
||||
new GameUpdateRequest()
|
||||
.setType(GameActionTypeProto.MOVE)
|
||||
.setDirectionX(direction.x)
|
||||
.setDirectionY(direction.y);
|
||||
case TankAction.STOP:
|
||||
new GameUpdateRequest()
|
||||
.setType(GameActionTypeProto.STOP);
|
||||
case TankAction.SHOT:
|
||||
new GameUpdateRequest()
|
||||
.setType(GameActionTypeProto.SHOT);
|
||||
case _: null;
|
||||
}
|
||||
if (update != null) {
|
||||
|
||||
@@ -19,7 +19,7 @@ class SoundManager {
|
||||
public function new() {}
|
||||
|
||||
public function play(id:String):Void {
|
||||
L.d(TAG, 'play: ${id}');
|
||||
//L.d(TAG, 'play: ${id}');
|
||||
var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}');
|
||||
if (sound != null) {
|
||||
sound.play();
|
||||
|
||||
Reference in New Issue
Block a user