udpate
This commit is contained in:
@@ -10,4 +10,4 @@ user = fetch(:user)
|
|||||||
server host, ssh_options: { port: 22, user: user, forward_agent: true }
|
server host, ssh_options: { port: 22, user: user, forward_agent: true }
|
||||||
|
|
||||||
set :tmp_dir, "/home/#{user}/tmp"
|
set :tmp_dir, "/home/#{user}/tmp"
|
||||||
set :branch, 'master'
|
set :branch, 'develop'
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"protoPath": ".",
|
"protoPath": "src/common/proto",
|
||||||
"protoFiles": [
|
"protoFiles": [
|
||||||
"src/common/proto/base.proto"
|
"src/common/proto/core.proto",
|
||||||
|
"src/common/proto/game.proto",
|
||||||
|
"src/common/proto/pack.proto"
|
||||||
],
|
],
|
||||||
"cleanOut": true,
|
"cleanOut": true,
|
||||||
"haxeOut": "src-gen/haxe",
|
"haxeOut": "src-gen/haxe",
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 3,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"pWidth": 100, "height": 44, "text": "Authorization",
|
|
||||||
"@style": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.HGroupView",
|
|
||||||
"contentSize": true,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"width": 150, "height": 44, "text": "Login",
|
|
||||||
"@style": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "loginInput", "@type": "haxework.gui.InputView",
|
|
||||||
"width": 220, "height": 44, "text": "",
|
|
||||||
"@style": "input"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.HGroupView",
|
|
||||||
"contentSize": true,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"width": 150, "height": 44, "text": "Password",
|
|
||||||
"@style": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "passwordInput", "@type": "haxework.gui.InputView",
|
|
||||||
"width": 220, "height": 44, "text": "",
|
|
||||||
"@style": "input"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
"id": "authButton",
|
|
||||||
"@type": "haxework.gui.ButtonView",
|
|
||||||
"width": 132, "height": 44,
|
|
||||||
"text": "Submit",
|
|
||||||
"@style": "button_skin"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "create", "@type": "haxework.gui.ButtonView",
|
|
||||||
"width": 132, "height": 44,
|
|
||||||
"text": "Create",
|
|
||||||
"@style": "button_skin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Game>",
|
|
||||||
"factory": "@class:ru.m.tankz.view.frames.list.GameView",
|
|
||||||
"scroll": {
|
|
||||||
"@type": "haxework.gui.list.VScrollView",
|
|
||||||
"skin": {"@type": "haxework.gui.list.VScrollSkin"}
|
|
||||||
},
|
|
||||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 5
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "start", "@type": "haxework.gui.ButtonView",
|
|
||||||
"width": 132, "height": 44,
|
|
||||||
"text": "Start",
|
|
||||||
"@style": "button_skin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "exit", "@type": "haxework.gui.ButtonView",
|
|
||||||
"width": 132, "height": 44,
|
|
||||||
"text": "Exit",
|
|
||||||
"@style": "button_skin"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Person>",
|
|
||||||
"factory": "@class:ru.m.tankz.view.frames.list.PersonView",
|
|
||||||
"scroll": {
|
|
||||||
"@type": "haxework.gui.list.VScrollView",
|
|
||||||
"skin": {"@type": "haxework.gui.list.VScrollSkin"}
|
|
||||||
},
|
|
||||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 5
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 3, "paddings": 10,
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"@type": "haxework.gui.LabelView",
|
|
||||||
"pWidth": 100, "height": 44, "text": "Person select",
|
|
||||||
"@style": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Person>",
|
|
||||||
"factory": "@class:ru.m.tankz.view.frames.list.PersonView",
|
|
||||||
"scroll": {
|
|
||||||
"@type": "haxework.gui.list.VScrollView",
|
|
||||||
"skin": {"@type": "haxework.gui.list.VScrollSkin"}
|
|
||||||
},
|
|
||||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 5
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -2,30 +2,6 @@
|
|||||||
"@type": "haxework.gui.VGroupView",
|
"@type": "haxework.gui.VGroupView",
|
||||||
"pWidth": 100, "pHeight": 100,
|
"pWidth": 100, "pHeight": 100,
|
||||||
"views": [
|
"views": [
|
||||||
{
|
|
||||||
"visible": false, "inLayout": false,
|
|
||||||
"id":"top", "@type": "haxework.gui.HGroupView",
|
|
||||||
"pWidth": 100, "height": 44,
|
|
||||||
"skin": {
|
|
||||||
"@type": "haxework.gui.skin.BitmapSkin",
|
|
||||||
"image": "@asset:image:resources/images/map/map_5.png",
|
|
||||||
"fillType": "REPEAT"
|
|
||||||
},
|
|
||||||
"views": [
|
|
||||||
{
|
|
||||||
"id": "name", "@type": "haxework.gui.LabelView",
|
|
||||||
"pWidth": 100, "height": 44,
|
|
||||||
"text": "@res:text:userName",
|
|
||||||
"@style": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "logout", "@type": "haxework.gui.ButtonView",
|
|
||||||
"width": 132, "height": 44,
|
|
||||||
"text": "Logout",
|
|
||||||
"@style": "button_skin"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
|
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
|
||||||
"pWidth": 100, "pHeight": 100,
|
"pWidth": 100, "pHeight": 100,
|
||||||
@@ -39,22 +15,6 @@
|
|||||||
"id": "start",
|
"id": "start",
|
||||||
"@type": "ru.m.tankz.view.frames.StartFrame"
|
"@type": "ru.m.tankz.view.frames.StartFrame"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "auth",
|
|
||||||
"@type": "ru.m.tankz.view.frames.AuthFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "person_list",
|
|
||||||
"@type": "ru.m.tankz.view.frames.PersonListFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "game_list",
|
|
||||||
"@type": "ru.m.tankz.view.frames.GameListFrame"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "game_ready",
|
|
||||||
"@type": "ru.m.tankz.view.frames.GameReadyFrame"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "game",
|
"id": "game",
|
||||||
"@type": "ru.m.tankz.view.frames.GameFrame"
|
"@type": "ru.m.tankz.view.frames.GameFrame"
|
||||||
|
|||||||
@@ -12,10 +12,8 @@ import flash.display.Sprite;
|
|||||||
import haxework.gui.IGroupView;
|
import haxework.gui.IGroupView;
|
||||||
import ru.m.tankz.PacketBuilder;
|
import ru.m.tankz.PacketBuilder;
|
||||||
import haxework.log.JSLogger;
|
import haxework.log.JSLogger;
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
import haxework.provider.Provider;
|
import haxework.provider.Provider;
|
||||||
import ru.m.tankz.view.frames.AuthFrame;
|
|
||||||
import haxework.gui.frame.FrameSwitcher;
|
import haxework.gui.frame.FrameSwitcher;
|
||||||
import haxework.gui.Root;
|
import haxework.gui.Root;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
@@ -49,7 +47,6 @@ class Client implements IConnectionHandler {
|
|||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
Provider.setFactory(IResources, Resources);
|
Provider.setFactory(IResources, Resources);
|
||||||
Provider.setFactory(GameData, GameData);
|
|
||||||
|
|
||||||
var font:Font = Font.enumerateFonts()[0];
|
var font:Font = Font.enumerateFonts()[0];
|
||||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
||||||
@@ -66,7 +63,7 @@ class Client implements IConnectionHandler {
|
|||||||
view = new MainView();
|
view = new MainView();
|
||||||
Provider.set(IFrameSwitcher, view.switcher);
|
Provider.set(IFrameSwitcher, view.switcher);
|
||||||
Root.bind(view);
|
Root.bind(view);
|
||||||
view.logout.onPress = this;
|
//view.logout.onPress = this;
|
||||||
view.switcher.change(StartFrame.ID);
|
view.switcher.change(StartFrame.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,11 +77,11 @@ class Client implements IConnectionHandler {
|
|||||||
public function onConnected():Void {}
|
public function onConnected():Void {}
|
||||||
|
|
||||||
public function onDisconnected():Void {
|
public function onDisconnected():Void {
|
||||||
view.switcher.change(AuthFrame.ID);
|
//view.switcher.change(AuthFrame.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onError(error:Dynamic):Void {
|
public function onError(error:Dynamic):Void {
|
||||||
L.e(TAG, "", error);
|
L.e(TAG, "", error);
|
||||||
view.switcher.change(AuthFrame.ID);
|
//view.switcher.change(AuthFrame.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package ru.m.tankz.data;
|
|
||||||
|
|
||||||
import ru.m.tankz.proto.Game;
|
|
||||||
import ru.m.tankz.proto.Person;
|
|
||||||
import ru.m.tankz.proto.Account;
|
|
||||||
|
|
||||||
class GameData {
|
|
||||||
public var account:Account;
|
|
||||||
public var person:Person;
|
|
||||||
public var players:Array<Person>;
|
|
||||||
public var game:Game;
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package ru.m.tankz.view.frames;
|
|
||||||
|
|
||||||
import haxework.resources.IResources;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import ru.m.core.connect.IConnection;
|
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import flash.net.SharedObject;
|
|
||||||
import ru.m.tankz.proto.ErrorResponse;
|
|
||||||
import protohx.Message;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
|
||||||
import ru.m.tankz.proto.LoginRequest;
|
|
||||||
import ru.m.tankz.proto.LoginResponse;
|
|
||||||
import haxework.provider.Provider;
|
|
||||||
import haxe.crypto.Md5;
|
|
||||||
import haxework.gui.InputView;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
|
|
||||||
@:template("layout/frames/auth.json", "layout/styles.json")
|
|
||||||
class AuthFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements IConnectionHandler {
|
|
||||||
|
|
||||||
private static inline var TAG = "AuthFrame";
|
|
||||||
|
|
||||||
public static inline var ID = "auth";
|
|
||||||
|
|
||||||
private var so:SharedObject;
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
so = SharedObject.getLocal("auth", "/");
|
|
||||||
authButton.onPress = this;
|
|
||||||
passwordInput.textField.displayAsPassword = true;
|
|
||||||
if (so.data.login != null && so.data.password != null) {
|
|
||||||
loginInput.text = so.data.login;
|
|
||||||
passwordInput.text = so.data.password;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onShow() {
|
|
||||||
Provider.get(IConnection).handler.addListener(this);
|
|
||||||
Provider.get(IConnection).packetHandler.addListener(this);
|
|
||||||
if (so.data.login != null && so.data.password != null) {
|
|
||||||
loginInput.text = so.data.login;
|
|
||||||
passwordInput.text = so.data.password;
|
|
||||||
//onPress(null);
|
|
||||||
} else {
|
|
||||||
loginInput.text = "shmyga";
|
|
||||||
passwordInput.text = "xkbp8jh9z2";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHide() {
|
|
||||||
Provider.get(IConnection).handler.removeListener(this);
|
|
||||||
Provider.get(IConnection).packetHandler.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPress(_) {
|
|
||||||
Provider.get(IConnection).connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IPacketHandler
|
|
||||||
**/
|
|
||||||
public function onLoginResponse(packet:LoginResponse):Void {
|
|
||||||
so.setProperty("login", loginInput.text);
|
|
||||||
so.setProperty("password", passwordInput.text);
|
|
||||||
so.flush();
|
|
||||||
Provider.get(IResources).text.put("userName", packet.account.login);
|
|
||||||
Provider.get(GameData).account = packet.account;
|
|
||||||
Provider.get(IFrameSwitcher).change(PersonListFrame.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onErrorResponse(packet:ErrorResponse):Void {
|
|
||||||
L.e(TAG, packet.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPacket(packet:Message):Void {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IConnectionHandler
|
|
||||||
**/
|
|
||||||
public function onConnected():Void {
|
|
||||||
Provider.get(IConnection).send(
|
|
||||||
new LoginRequest()
|
|
||||||
.setLogin(loginInput.text)
|
|
||||||
.setPassword(Md5.encode(passwordInput.text))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onDisconnected():Void {}
|
|
||||||
|
|
||||||
public function onError(error:Dynamic):Void {
|
|
||||||
L.e(TAG, "Auth", error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.view.frames;
|
||||||
|
|
||||||
|
import ru.m.tankz.proto.core.GameType;
|
||||||
|
import ru.m.tankz.proto.core.Game;
|
||||||
import ru.m.tankz.core.PlayerControl;
|
import ru.m.tankz.core.PlayerControl;
|
||||||
import ru.m.tankz.engine.Engine;
|
import ru.m.tankz.engine.Engine;
|
||||||
import ru.m.tankz.engine.IEngine;
|
import ru.m.tankz.engine.IEngine;
|
||||||
import protohx.Message;
|
import protohx.Message;
|
||||||
import ru.m.tankz.proto.GameUpdateResponse;
|
import ru.m.tankz.proto.pack.GameUpdateResponse;
|
||||||
import ru.m.core.connect.IConnection;
|
import ru.m.core.connect.IConnection;
|
||||||
import haxework.gui.ViewBuilder;
|
import haxework.gui.ViewBuilder;
|
||||||
import ru.m.tankz.config.TankzConfig;
|
import ru.m.tankz.config.TankzConfig;
|
||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
import haxework.provider.Provider;
|
import haxework.provider.Provider;
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import haxework.gui.VGroupView;
|
import haxework.gui.VGroupView;
|
||||||
|
|
||||||
@:template("layout/frames/game.json", "layout/styles.json")
|
@:template("layout/frames/game.json", "layout/styles.json")
|
||||||
@@ -29,12 +30,12 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onShow():Void {
|
public function onShow():Void {
|
||||||
var data:GameData = Provider.get(GameData);
|
var game:Game = Provider.get(Game);
|
||||||
engine.init(DEFAULT.CONFIG);
|
engine.init(ConfigData.get(GameType.CLASSIC));
|
||||||
engine.initTanks(data.game.persons); // ToDo:
|
engine.initTanks(game.players);
|
||||||
content.addEventListener(Event.ENTER_FRAME, updateGame);
|
content.addEventListener(Event.ENTER_FRAME, updateGame);
|
||||||
for (index in 0...data.players.length) {
|
for (index in 0...game.players.length) {
|
||||||
var playerId:Int = data.players[index].id;
|
var playerId:Int = game.players[index].id;
|
||||||
controls.set(playerId, PlayerControl.forPlayer(index, playerId, engine));
|
controls.set(playerId, PlayerControl.forPlayer(index, playerId, engine));
|
||||||
}
|
}
|
||||||
Provider.get(IConnection).packetHandler.addListener(this);
|
Provider.get(IConnection).packetHandler.addListener(this);
|
||||||
@@ -53,7 +54,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onGameUpdateResponse(packet:GameUpdateResponse):Void {
|
public function onGameUpdateResponse(packet:GameUpdateResponse):Void {
|
||||||
engine.updateFromChanges(packet.changes);
|
//engine.updateFromChanges(packet.changes);
|
||||||
render.draw(engine);
|
render.draw(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
package ru.m.tankz.view.frames;
|
|
||||||
|
|
||||||
import ru.m.tankz.proto.GamesUnSubscribeRequest;
|
|
||||||
import ru.m.tankz.proto.GamesSubscribeRequest;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import ru.m.tankz.proto.JoinGameResponse;
|
|
||||||
import ru.m.tankz.proto.JoinGameRequest;
|
|
||||||
import ru.m.tankz.proto.CreateGameResponse;
|
|
||||||
import ru.m.tankz.proto.CreateGameRequest;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import haxework.gui.LabelView;
|
|
||||||
import ru.m.tankz.proto.GamesResponse;
|
|
||||||
import ru.m.tankz.proto.Game;
|
|
||||||
import haxework.gui.list.ListView;
|
|
||||||
import protohx.Message;
|
|
||||||
import ru.m.core.connect.IConnection;
|
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import haxework.provider.Provider;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
|
|
||||||
@:template("layout/frames/game_list.json", "layout/styles.json")
|
|
||||||
class GameListFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Game> {
|
|
||||||
|
|
||||||
private static inline var TAG = "GameListFrame";
|
|
||||||
|
|
||||||
public static inline var ID = "game_list";
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
list.dispatcher.addListener(this);
|
|
||||||
findViewById("create", ButtonView).onPress = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onShow() {
|
|
||||||
Provider.get(IConnection).packetHandler.addListener(this);
|
|
||||||
Provider.get(IConnection).send(new GamesSubscribeRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHide() {
|
|
||||||
Provider.get(IConnection).send(new GamesUnSubscribeRequest());
|
|
||||||
Provider.get(IConnection).packetHandler.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onListItemClick(item:IListItemView<Game>):Void {
|
|
||||||
L.d(TAG, "game selected: ", item.data.id);
|
|
||||||
Provider.get(IConnection).send(new JoinGameRequest().setGameId(item.data.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onGamesResponse(packet:GamesResponse):Void {
|
|
||||||
list.data = packet.games;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onCreateGameResponse(packet:CreateGameResponse):Void {
|
|
||||||
//list.data.push(packet.game);
|
|
||||||
//list.update();
|
|
||||||
Provider.get(GameData).game = packet.game;
|
|
||||||
Provider.get(IFrameSwitcher).change(GameReadyFrame.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onJoinGameResponse(packet:JoinGameResponse):Void {
|
|
||||||
Provider.get(GameData).game = packet.game;
|
|
||||||
Provider.get(IFrameSwitcher).change(GameReadyFrame.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPacket(packet:Message):Void {}
|
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
|
||||||
switch (view.id) {
|
|
||||||
case "create":
|
|
||||||
Provider.get(IConnection).send(new CreateGameRequest());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
package ru.m.tankz.view.frames;
|
|
||||||
|
|
||||||
import ru.m.tankz.proto.LeaveGameRequest;
|
|
||||||
import ru.m.tankz.proto.LeaveGameResponse;
|
|
||||||
import ru.m.tankz.proto.JoinGameResponse;
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
|
||||||
import ru.m.tankz.proto.StartGameResponse;
|
|
||||||
import ru.m.tankz.proto.StartGameRequest;
|
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import protohx.Message;
|
|
||||||
import haxework.gui.ButtonView;
|
|
||||||
import haxework.provider.Provider;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
import ru.m.core.connect.IConnection;
|
|
||||||
|
|
||||||
@:template("layout/frames/game_ready.json", "layout/styles.json")
|
|
||||||
class GameReadyFrame extends VGroupView implements ViewBuilder implements IPacketHandler {
|
|
||||||
|
|
||||||
private static inline var TAG = "GameReadyFrame";
|
|
||||||
|
|
||||||
public static inline var ID = "game_ready";
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
//list.dispatcher.addListener(this);
|
|
||||||
findViewById("start", ButtonView).onPress = this;
|
|
||||||
findViewById("exit", ButtonView).onPress = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onShow() {
|
|
||||||
Provider.get(IConnection).packetHandler.addListener(this);
|
|
||||||
list.data = Provider.get(GameData).game.persons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHide() {
|
|
||||||
Provider.get(IConnection).packetHandler.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onStartGameResponse(packet:StartGameResponse):Void {
|
|
||||||
Provider.get(GameData).game = packet.game;
|
|
||||||
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;
|
|
||||||
var person = Provider.get(GameData).person;
|
|
||||||
if (!Lambda.exists(packet.game.persons, function(person) return person.id == person.id)) {
|
|
||||||
Provider.get(GameData).game = null;
|
|
||||||
Provider.get(IFrameSwitcher).change(GameListFrame.ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPacket(packet:Message):Void {}
|
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
|
||||||
switch (view.id) {
|
|
||||||
case "start":
|
|
||||||
Provider.get(IConnection).send(new StartGameRequest());
|
|
||||||
case "exit":
|
|
||||||
Provider.get(IConnection).send(new LeaveGameRequest());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package ru.m.tankz.view.frames;
|
|
||||||
|
|
||||||
import haxework.gui.ViewBuilder;
|
|
||||||
import ru.m.tankz.view.frames.GameListFrame;
|
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
|
||||||
import ru.m.tankz.proto.PersonSelectResponse;
|
|
||||||
import ru.m.tankz.proto.PersonSelectRequest;
|
|
||||||
import haxework.gui.list.ListView;
|
|
||||||
import protohx.Message;
|
|
||||||
import ru.m.core.connect.IConnection;
|
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import haxework.provider.Provider;
|
|
||||||
import ru.m.tankz.proto.Person;
|
|
||||||
import haxework.gui.VGroupView;
|
|
||||||
|
|
||||||
@:template("layout/frames/person_list.json", "layout/styles.json")
|
|
||||||
class PersonListFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Person> {
|
|
||||||
|
|
||||||
private static inline var TAG = "PersonListFrame";
|
|
||||||
|
|
||||||
public static inline var ID = "person_list";
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
list = findViewById("list");
|
|
||||||
list.dispatcher.addListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onShow() {
|
|
||||||
list.data = Provider.get(GameData).account.persons;
|
|
||||||
Provider.get(IConnection).packetHandler.addListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHide() {
|
|
||||||
Provider.get(IConnection).packetHandler.removeListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onListItemClick(item:IListItemView<Person>):Void {
|
|
||||||
Provider.get(IConnection).send(new PersonSelectRequest().setPersonId(item.data.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPersonSelectResponse(packet:PersonSelectResponse):Void {
|
|
||||||
Provider.get(GameData).person = packet.person;
|
|
||||||
Provider.get(IFrameSwitcher).change(GameListFrame.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onPacket(packet:Message):Void {}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.m.tankz.view.frames;
|
package ru.m.tankz.view.frames;
|
||||||
|
|
||||||
import ru.m.tankz.proto.Person;
|
import ru.m.tankz.proto.core.GameType;
|
||||||
import ru.m.tankz.proto.Game;
|
import ru.m.tankz.proto.core.Player;
|
||||||
|
import ru.m.tankz.proto.core.Game;
|
||||||
import haxework.gui.frame.IFrameSwitcher;
|
import haxework.gui.frame.IFrameSwitcher;
|
||||||
import ru.m.tankz.data.GameData;
|
|
||||||
import haxework.provider.Provider;
|
import haxework.provider.Provider;
|
||||||
import haxework.gui.ButtonView;
|
import haxework.gui.ButtonView;
|
||||||
import haxework.gui.ViewBuilder;
|
import haxework.gui.ViewBuilder;
|
||||||
@@ -30,14 +30,14 @@ class StartFrame extends VGroupView implements ViewBuilder {
|
|||||||
|
|
||||||
private function startGame(playersCount:Int):Void {
|
private function startGame(playersCount:Int):Void {
|
||||||
var game = new Game();
|
var game = new Game();
|
||||||
|
game.type = GameType.CLASSIC;
|
||||||
for (i in 0...playersCount) {
|
for (i in 0...playersCount) {
|
||||||
var player = new Person();
|
var player = new Player();
|
||||||
player.id = i;
|
player.id = i;
|
||||||
game.persons.push(player);
|
game.players.push(player);
|
||||||
}
|
}
|
||||||
game.id = 1;
|
game.id = 1;
|
||||||
Provider.get(GameData).players = game.persons;
|
Provider.set(Game, game);
|
||||||
Provider.get(GameData).game = game;
|
|
||||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
import ru.m.tankz.proto.LeaveGameRequest;
|
import ru.m.tankz.proto.pack.LeaveGameRequest;
|
||||||
import ru.m.tankz.proto.LeaveGameResponse;
|
import ru.m.tankz.proto.pack.LeaveGameResponse;
|
||||||
import ru.m.tankz.proto.GameUpdateResponse;
|
import ru.m.tankz.proto.pack.GameUpdateResponse;
|
||||||
import ru.m.tankz.proto.GameActionRequest;
|
import ru.m.tankz.proto.pack.GameActionRequest;
|
||||||
import ru.m.core.connect.IConnection;
|
import ru.m.core.connect.IConnection;
|
||||||
import protohx.Message;
|
import protohx.Message;
|
||||||
import ru.m.tankz.proto.LoginRequest;
|
import ru.m.tankz.proto.pack.ErrorResponse;
|
||||||
import ru.m.tankz.proto.LoginResponse;
|
import ru.m.tankz.proto.pack.GameListRequest;
|
||||||
import ru.m.tankz.proto.PersonSelectRequest;
|
import ru.m.tankz.proto.pack.GameListResponse;
|
||||||
import ru.m.tankz.proto.PersonSelectResponse;
|
import ru.m.tankz.proto.pack.CreateGameRequest;
|
||||||
import ru.m.tankz.proto.ErrorResponse;
|
import ru.m.tankz.proto.pack.CreateGameResponse;
|
||||||
import ru.m.tankz.proto.GamesSubscribeRequest;
|
import ru.m.tankz.proto.pack.JoinGameRequest;
|
||||||
import ru.m.tankz.proto.GamesUnSubscribeRequest;
|
import ru.m.tankz.proto.pack.JoinGameResponse;
|
||||||
import ru.m.tankz.proto.GamesResponse;
|
import ru.m.tankz.proto.pack.StartGameRequest;
|
||||||
import ru.m.tankz.proto.CreateGameRequest;
|
import ru.m.tankz.proto.pack.StartGameResponse;
|
||||||
import ru.m.tankz.proto.CreateGameResponse;
|
|
||||||
import ru.m.tankz.proto.JoinGameRequest;
|
|
||||||
import ru.m.tankz.proto.JoinGameResponse;
|
|
||||||
import ru.m.tankz.proto.StartGameRequest;
|
|
||||||
import ru.m.tankz.proto.StartGameResponse;
|
|
||||||
|
|
||||||
class PacketBuilder implements IPacketBuilder {
|
class PacketBuilder implements IPacketBuilder {
|
||||||
|
|
||||||
@@ -27,24 +22,21 @@ class PacketBuilder implements IPacketBuilder {
|
|||||||
0x00 => [
|
0x00 => [
|
||||||
0x0001 => ErrorResponse
|
0x0001 => ErrorResponse
|
||||||
],
|
],
|
||||||
0x01 => [
|
/*0x01 => [
|
||||||
0x0001 => LoginRequest,
|
|
||||||
0x0002 => LoginResponse,
|
],*/
|
||||||
0x0003 => PersonSelectRequest,
|
|
||||||
0x0004 => PersonSelectResponse
|
|
||||||
],
|
|
||||||
0x02 => [
|
0x02 => [
|
||||||
0x0001 => GamesSubscribeRequest,
|
0x0001 => GameListRequest,
|
||||||
0x0002 => GamesResponse,
|
0x0002 => GameListResponse,
|
||||||
0x0003 => CreateGameRequest,
|
0x0003 => CreateGameRequest,
|
||||||
0x0004 => CreateGameResponse,
|
0x0004 => CreateGameResponse,
|
||||||
0x0005 => JoinGameRequest,
|
0x0005 => GameListResponse,
|
||||||
0x0006 => JoinGameResponse,
|
0x0006 => JoinGameRequest,
|
||||||
0x0007 => StartGameRequest,
|
0x0007 => JoinGameResponse,
|
||||||
0x0008 => StartGameResponse,
|
0x0008 => StartGameRequest,
|
||||||
0x0009 => LeaveGameRequest,
|
0x0009 => StartGameResponse,
|
||||||
0x000a => LeaveGameResponse,
|
0x000a => LeaveGameRequest,
|
||||||
0x000b => GamesUnSubscribeRequest
|
0x000b => LeaveGameResponse
|
||||||
],
|
],
|
||||||
0x03 => [
|
0x03 => [
|
||||||
0x0001 => GameActionRequest,
|
0x0001 => GameActionRequest,
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package ru.m.tankz.config;
|
package ru.m.tankz.config;
|
||||||
|
|
||||||
|
import ru.m.tankz.proto.core.GameType;
|
||||||
|
import ru.m.tankz.core.Direction;
|
||||||
|
|
||||||
typedef MapConfig = {
|
typedef MapConfig = {
|
||||||
var cellWidth:Float;
|
var cellWidth:Float;
|
||||||
var cellHeight:Float;
|
var cellHeight:Float;
|
||||||
@@ -7,17 +10,66 @@ typedef MapConfig = {
|
|||||||
var gridHeight:Int;
|
var gridHeight:Int;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TankzConfig = {
|
enum SpawnPointType {
|
||||||
var map:MapConfig;
|
PLAYER;
|
||||||
|
BOT;
|
||||||
|
EAGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DEFAULT {
|
typedef SpawnPoint = {
|
||||||
public static var CONFIG:TankzConfig = {
|
var type:SpawnPointType;
|
||||||
|
var index:Int;
|
||||||
|
var x:Int;
|
||||||
|
var y:Int;
|
||||||
|
var direction:Direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef TankzConfig = {
|
||||||
|
var map:MapConfig;
|
||||||
|
var points:Array<SpawnPoint>;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfigData {
|
||||||
|
public static var CLASSIC:TankzConfig = {
|
||||||
map: {
|
map: {
|
||||||
cellWidth: 22,
|
cellWidth: 22,
|
||||||
cellHeight: 22,
|
cellHeight: 22,
|
||||||
gridWidth: 26,
|
gridWidth: 26,
|
||||||
gridHeight: 26
|
gridHeight: 26
|
||||||
|
},
|
||||||
|
points: [
|
||||||
|
{
|
||||||
|
type: SpawnPointType.PLAYER,
|
||||||
|
index: 0,
|
||||||
|
x: 8,
|
||||||
|
y: 24,
|
||||||
|
direction: Direction.TOP
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: SpawnPointType.PLAYER,
|
||||||
|
index: 1,
|
||||||
|
x: 16,
|
||||||
|
y: 24,
|
||||||
|
direction: Direction.TOP
|
||||||
}
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static function get(type:Int):TankzConfig {
|
||||||
|
switch (type) {
|
||||||
|
case GameType.CLASSIC:
|
||||||
|
return CLASSIC;
|
||||||
|
case _:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function findSpawnPoint(config:TankzConfig, type:SpawnPointType, index:Int):SpawnPoint {
|
||||||
|
for (point in config.points) {
|
||||||
|
if (point.type == type && point.index == index) {
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package ru.m.tankz.engine;
|
package ru.m.tankz.engine;
|
||||||
|
|
||||||
import ru.m.tankz.core.Bullet;
|
import ru.m.tankz.core.Bullet;
|
||||||
import ru.m.tankz.proto.GameObjectType;
|
import ru.m.tankz.proto.game.GameObjectType;
|
||||||
import ru.m.tankz.proto.GameChangeType;
|
import ru.m.tankz.proto.game.GameChangeType;
|
||||||
import ru.m.tankz.proto.GameChange;
|
import ru.m.tankz.proto.game.GameChange;
|
||||||
import ru.m.tankz.proto.Person;
|
import ru.m.tankz.proto.core.Player;
|
||||||
import ru.m.tankz.core.Direction;
|
import ru.m.tankz.core.Direction;
|
||||||
import ru.m.tankz.core.IMobileEntity;
|
import ru.m.tankz.core.IMobileEntity;
|
||||||
//import flash.geom.Rectangle;
|
//import flash.geom.Rectangle;
|
||||||
@@ -30,8 +30,8 @@ class Engine implements IEngine {
|
|||||||
tanks = new Map<Int, Tank>();
|
tanks = new Map<Int, Tank>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildTank(personId:Int, id:Int, x:Float, y:Float, direction:Direction):Tank {
|
private function buildTank(personId:Int, id:Int, cellX:Float, cellY:Float, direction:Direction):Tank {
|
||||||
return new Tank(personId, id, x, y, direction);
|
return new Tank(personId, id, cellX * map.cellWidth, cellY * map.cellHeight, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init(config:TankzConfig):Void {
|
public function init(config:TankzConfig):Void {
|
||||||
@@ -43,18 +43,17 @@ class Engine implements IEngine {
|
|||||||
y_limit = map.gridHeight * map.cellHeight;
|
y_limit = map.gridHeight * map.cellHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initTanks(persons:Array<Person>):Array<GameChange> {
|
public function initTanks(players:Array<Player>):Array<GameChange> {
|
||||||
var changes = new Array<GameChange>();
|
var changes = new Array<GameChange>();
|
||||||
for (person in persons) {
|
for (index in 0...players.length) {
|
||||||
var x = 0;
|
var player:Player = players[index];
|
||||||
var y = 100 * persons.indexOf(person);
|
var point:SpawnPoint = ConfigData.findSpawnPoint(config, SpawnPointType.PLAYER, index);
|
||||||
var tank = buildTank(person.id, 0, x, y, Direction.BOTTOM);
|
var tank = buildTank(player.id, 0, point.x, point.y, point.direction);
|
||||||
this.tanks.set(tank.personId, tank);
|
this.tanks.set(tank.personId, tank);
|
||||||
this.mobileEntities.set(tank.id, tank);
|
this.mobileEntities.set(tank.id, tank);
|
||||||
changes.push(new GameChange()
|
changes.push(new GameChange()
|
||||||
.setType(GameChangeType.APPEND)
|
.setType(GameChangeType.APPEND)
|
||||||
.setObjectType(GameObjectType.TANK)
|
.setObjectType(GameObjectType.TANK)
|
||||||
.setPersonId(tank.personId)
|
|
||||||
.setObjectId(tank.id)
|
.setObjectId(tank.id)
|
||||||
.setX(tank.x)
|
.setX(tank.x)
|
||||||
.setY(tank.y)
|
.setY(tank.y)
|
||||||
@@ -94,7 +93,7 @@ class Engine implements IEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateFromChanges(changes:Array<GameChange>):Void {
|
/*public function updateFromChanges(changes:Array<GameChange>):Void {
|
||||||
for (change in changes) {
|
for (change in changes) {
|
||||||
switch (change.type) {
|
switch (change.type) {
|
||||||
case GameChangeType.APPEND:
|
case GameChangeType.APPEND:
|
||||||
@@ -117,10 +116,10 @@ class Engine implements IEngine {
|
|||||||
target.x = change.x;
|
target.x = change.x;
|
||||||
target.y = change.y;
|
target.y = change.y;
|
||||||
case GameChangeType.MODIFIED:
|
case GameChangeType.MODIFIED:
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
public function update():Array<GameChange> {
|
public function update():Array<GameChange> {
|
||||||
var changes = new Array<GameChange>();
|
var changes = new Array<GameChange>();
|
||||||
@@ -173,7 +172,6 @@ class Engine implements IEngine {
|
|||||||
changes.push(new GameChange()
|
changes.push(new GameChange()
|
||||||
.setType(GameChangeType.MOVED)
|
.setType(GameChangeType.MOVED)
|
||||||
.setObjectType(objectType)
|
.setObjectType(objectType)
|
||||||
.setPersonId(personId)
|
|
||||||
.setObjectId(entiny.id)
|
.setObjectId(entiny.id)
|
||||||
.setX(entiny.x)
|
.setX(entiny.x)
|
||||||
.setY(entiny.y)
|
.setY(entiny.y)
|
||||||
@@ -187,7 +185,6 @@ class Engine implements IEngine {
|
|||||||
changes.push(new GameChange()
|
changes.push(new GameChange()
|
||||||
.setType(GameChangeType.DESTROED)
|
.setType(GameChangeType.DESTROED)
|
||||||
.setObjectType(objectType)
|
.setObjectType(objectType)
|
||||||
.setPersonId(personId)
|
|
||||||
.setObjectId(entiny.id)
|
.setObjectId(entiny.id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.m.tankz.engine;
|
package ru.m.tankz.engine;
|
||||||
|
|
||||||
import ru.m.tankz.proto.GameChange;
|
import ru.m.tankz.proto.game.GameChange;
|
||||||
import ru.m.tankz.core.IMobileEntity;
|
import ru.m.tankz.core.IMobileEntity;
|
||||||
import ru.m.tankz.core.Tank;
|
import ru.m.tankz.core.Tank;
|
||||||
import ru.m.tankz.proto.Person;
|
import ru.m.tankz.proto.core.Player;
|
||||||
import ru.m.tankz.config.TankzConfig;
|
import ru.m.tankz.config.TankzConfig;
|
||||||
import ru.m.tankz.map.ITankzMap;
|
import ru.m.tankz.map.ITankzMap;
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ interface IEngine {
|
|||||||
|
|
||||||
public function clear():Void;
|
public function clear():Void;
|
||||||
public function init(config:TankzConfig):Void;
|
public function init(config:TankzConfig):Void;
|
||||||
public function initTanks(persons:Array<Person>):Array<GameChange>;
|
public function initTanks(players:Array<Player>):Array<GameChange>;
|
||||||
public function action(tankId:Int, action:TankAction):Void;
|
public function action(tankId:Int, action:TankAction):Void;
|
||||||
public function updateFromChanges(changes:Array<GameChange>):Void;
|
//public function updateFromChanges(changes:Array<GameChange>):Void;
|
||||||
public function update():Array<GameChange>;
|
public function update():Array<GameChange>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
package ru.m.tankz.proto;
|
|
||||||
|
|
||||||
message Person {
|
|
||||||
required int32 id = 1;
|
|
||||||
required string name = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Account {
|
|
||||||
required int32 id = 1;
|
|
||||||
required string login = 2;
|
|
||||||
repeated Person persons = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LoginRequest {
|
|
||||||
required string login = 1;
|
|
||||||
required string password = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LoginResponse {
|
|
||||||
required Account account = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PersonSelectRequest {
|
|
||||||
required int32 person_id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message PersonSelectResponse {
|
|
||||||
required Person person = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ErrorResponse {
|
|
||||||
required int32 code = 1;
|
|
||||||
required string message = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum GameState {
|
|
||||||
READY = 1;
|
|
||||||
STARTED = 2;
|
|
||||||
ENDED = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Game {
|
|
||||||
required int32 id = 1;
|
|
||||||
required Person creator = 2;
|
|
||||||
repeated Person persons = 3;
|
|
||||||
required GameState state = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GamesSubscribeRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message GamesUnSubscribeRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message GamesResponse {
|
|
||||||
repeated Game games = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateGameRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateGameResponse {
|
|
||||||
required Game game = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message JoinGameRequest {
|
|
||||||
required int32 game_id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message JoinGameResponse {
|
|
||||||
required Game game = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message LeaveGameRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message LeaveGameResponse {
|
|
||||||
required Game game = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message StartGameRequest {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message StartGameResponse {
|
|
||||||
required Game game = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Game
|
|
||||||
*/
|
|
||||||
enum GameActionType {
|
|
||||||
MOVE = 1;
|
|
||||||
SHOT = 2;
|
|
||||||
STOP = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GameActionRequest {
|
|
||||||
required GameActionType type = 1;
|
|
||||||
optional int32 directionX = 2;
|
|
||||||
optional int32 directionY = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum GameObjectType {
|
|
||||||
TANK = 1;
|
|
||||||
BULLET = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum GameChangeType {
|
|
||||||
MOVED = 1;
|
|
||||||
DESTROED = 2;
|
|
||||||
MODIFIED = 3;
|
|
||||||
APPEND = 4;
|
|
||||||
DIRECTION = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GameChange {
|
|
||||||
required GameChangeType type = 1;
|
|
||||||
required GameObjectType objectType = 2;
|
|
||||||
optional int32 personId = 3;
|
|
||||||
required int32 objectId = 4;
|
|
||||||
optional float x = 5;
|
|
||||||
optional float y = 6;
|
|
||||||
optional int32 directionX = 7;
|
|
||||||
optional int32 directionY = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GameUpdateResponse {
|
|
||||||
repeated GameChange changes = 1;
|
|
||||||
}
|
|
||||||
27
src/common/proto/core.proto
Normal file
27
src/common/proto/core.proto
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package ru.m.tankz.proto.core;
|
||||||
|
|
||||||
|
|
||||||
|
message Player {
|
||||||
|
int32 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameType {
|
||||||
|
CLASSIC = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameState {
|
||||||
|
READY = 0;
|
||||||
|
STARTED = 1;
|
||||||
|
ENDED = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Game {
|
||||||
|
int32 id = 1;
|
||||||
|
GameType type = 2;
|
||||||
|
Player creator = 3;
|
||||||
|
repeated Player players = 4;
|
||||||
|
GameState state = 5;
|
||||||
|
}
|
||||||
33
src/common/proto/game.proto
Normal file
33
src/common/proto/game.proto
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package ru.m.tankz.proto.game;
|
||||||
|
|
||||||
|
|
||||||
|
enum GameActionType {
|
||||||
|
MOVE = 0;
|
||||||
|
SHOT = 1;
|
||||||
|
STOP = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameObjectType {
|
||||||
|
TANK = 0;
|
||||||
|
BULLET = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameChangeType {
|
||||||
|
MOVED = 0;
|
||||||
|
DESTROED = 1;
|
||||||
|
MODIFIED = 2;
|
||||||
|
APPEND = 3;
|
||||||
|
DIRECTION = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GameChange {
|
||||||
|
GameChangeType type = 1;
|
||||||
|
GameObjectType objectType = 2;
|
||||||
|
int32 objectId = 3;
|
||||||
|
float x = 4;
|
||||||
|
float y = 5;
|
||||||
|
int32 directionX = 6;
|
||||||
|
int32 directionY = 7;
|
||||||
|
}
|
||||||
56
src/common/proto/pack.proto
Normal file
56
src/common/proto/pack.proto
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
import "core.proto";
|
||||||
|
import "game.proto";
|
||||||
|
|
||||||
|
package ru.m.tankz.proto.pack;
|
||||||
|
|
||||||
|
|
||||||
|
message ErrorResponse {
|
||||||
|
int32 code = 1;
|
||||||
|
string message = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GameListRequest {}
|
||||||
|
|
||||||
|
message GameListResponse {
|
||||||
|
repeated ru.m.tankz.proto.core.Game games = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateGameRequest {
|
||||||
|
ru.m.tankz.proto.core.GameType type = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateGameResponse {
|
||||||
|
ru.m.tankz.proto.core.Game game = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message JoinGameRequest {
|
||||||
|
int32 game_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message JoinGameResponse {
|
||||||
|
ru.m.tankz.proto.core.Game game = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LeaveGameRequest {}
|
||||||
|
|
||||||
|
message LeaveGameResponse {
|
||||||
|
ru.m.tankz.proto.core.Game game = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message StartGameRequest {}
|
||||||
|
|
||||||
|
message StartGameResponse {
|
||||||
|
ru.m.tankz.proto.core.Game game = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GameActionRequest {
|
||||||
|
ru.m.tankz.proto.game.GameActionType type = 1;
|
||||||
|
int32 directionX = 2;
|
||||||
|
int32 directionY = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GameUpdateResponse {
|
||||||
|
repeated ru.m.tankz.proto.game.GameChange changes = 1;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user