This commit is contained in:
2017-12-22 17:10:46 +03:00
parent 6345ddcd19
commit 0dd878224b
14 changed files with 88 additions and 136 deletions

View File

@@ -1,7 +1,5 @@
"use strict";
const gulp = require('gulp'); const gulp = require('gulp');
const yargs = require('yargs'); const yargs = require('yargs');
const tail = require('../tasks/tail');
const Haxe = require('../tasks/haxe'); const Haxe = require('../tasks/haxe');
const FlashPlayer = require('../tasks/flashplayer'); const FlashPlayer = require('../tasks/flashplayer');
const version = require('./version'); const version = require('./version');
@@ -26,7 +24,6 @@ const test = (build) => function test() {
const argv = yargs.argv; const argv = yargs.argv;
return build() return build()
.pipe(new FlashPlayer().run(argv.dev)) .pipe(new FlashPlayer().run(argv.dev))
//.pipe(tail(debug.log));
.pipe(debug()); .pipe(debug());
}; };

View File

@@ -1,7 +1,5 @@
"use strict";
const gulp = require('gulp'); const gulp = require('gulp');
const yargs = require('yargs'); const yargs = require('yargs');
const tail = require('../tasks/tail');
const Haxe = require('../tasks/haxe'); const Haxe = require('../tasks/haxe');
const FlashPlayer = require('../tasks/flashplayer'); const FlashPlayer = require('../tasks/flashplayer');
const Neko = require('../tasks/neko'); const Neko = require('../tasks/neko');

View File

@@ -0,0 +1,28 @@
{
"pWidth": 100, "pHeight": 100,
"views": [
{
"@type": "haxework.gui.ImageView",
"image": "@asset:image:resources/images/logo/logo.png",
"contentSize": true, "bottomMargin": 15
},
{
"id": "start_1p",
"@type": "haxework.gui.ButtonView",
"text": "1 Player",
"@style": "button"
},
{
"id": "start_2p",
"@type": "haxework.gui.ButtonView",
"text": "2 Player",
"@style": "button"
},
{
"id": "start_lan",
"@type": "haxework.gui.ButtonView",
"text": "Multiplayer",
"@style": "button"
}
]
}

View File

@@ -3,6 +3,7 @@
"pWidth": 100, "pHeight": 100, "pWidth": 100, "pHeight": 100,
"views": [ "views": [
{ {
"visible": false, "inLayout": false,
"id":"top", "@type": "haxework.gui.HGroupView", "id":"top", "@type": "haxework.gui.HGroupView",
"pWidth": 100, "height": 44, "pWidth": 100, "height": 44,
"skin": { "skin": {
@@ -34,6 +35,10 @@
"fillType": "REPEAT" "fillType": "REPEAT"
}, },
"views": [ "views": [
{
"id": "start",
"@type": "ru.m.tankz.view.frames.StartFrame"
},
{ {
"id": "auth", "id": "auth",
"@type": "ru.m.tankz.view.frames.AuthFrame" "@type": "ru.m.tankz.view.frames.AuthFrame"

View File

@@ -1,18 +1,6 @@
{ {
"_button_skin": { "button": {
"skin": { "width":250, "height":60,
"@type": "haxework.gui.skin.ButtonBitmapSkin",
"image": "@asset:image:resources/images/map/map_4.png",
"fillType": "REPEAT"
},
"fontColor": "0xffffff",
"fontEmbed": true,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000"
},
"button_skin": {
"skin": { "skin": {
"@type": "haxework.gui.skin.ButtonBitmapSkin", "@type": "haxework.gui.skin.ButtonBitmapSkin",
"upImage": "@asset:image:resources/images/control/button_normal.png", "upImage": "@asset:image:resources/images/control/button_normal.png",
@@ -20,7 +8,7 @@
"overImage": "@asset:image:resources/images/control/button_over.png", "overImage": "@asset:image:resources/images/control/button_over.png",
"fillType": "NINEPATH" "fillType": "NINEPATH"
}, },
"fontColor": "0xffffff" "fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20
}, },
"label": { "label": {

View File

@@ -1,5 +1,7 @@
package ru.m.tankz; package ru.m.tankz;
import flash.text.Font;
import ru.m.tankz.view.frames.StartFrame;
import haxework.log.SocketLogger; import haxework.log.SocketLogger;
import haxework.resources.Resources; import haxework.resources.Resources;
import haxework.resources.IResources; import haxework.resources.IResources;
@@ -49,9 +51,8 @@ class Client implements IConnectionHandler {
Provider.setFactory(IResources, Resources); Provider.setFactory(IResources, Resources);
Provider.setFactory(GameData, GameData); Provider.setFactory(GameData, GameData);
//var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF"); var font:Font = Font.enumerateFonts()[0];
//Provider.get(IResources).text.put("fontName", font.fontName); Provider.get(IResources).text.put("font", "Bookman Old Style");
Provider.get(IResources).text.put("fontName", "Arial");
Provider.set(IPacketBuilder, new PacketBuilder()); Provider.set(IPacketBuilder, new PacketBuilder());
#if flash #if flash
@@ -66,7 +67,7 @@ class Client implements IConnectionHandler {
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(AuthFrame.ID); view.switcher.change(StartFrame.ID);
} }
public function onPress(view:ButtonView):Void { public function onPress(view:ButtonView):Void {

View File

@@ -30,11 +30,11 @@ class PlayerTank extends Tank {
} }
case TankAction.SHOT: case TankAction.SHOT:
//ToDo: //ToDo:
//shot(); shot();
Provider.get(IConnection).send( /*Provider.get(IConnection).send(
new GameActionRequest() new GameActionRequest()
.setType(GameActionType.SHOT) .setType(GameActionType.SHOT)
); );*/
} }
} }
@@ -49,22 +49,22 @@ class PlayerTank extends Tank {
private function updateMove():Void { private function updateMove():Void {
if (moveQueue.length == 0) { if (moveQueue.length == 0) {
//stop(); stop();
Provider.get(IConnection).send( /*Provider.get(IConnection).send(
new GameActionRequest() new GameActionRequest()
.setType(GameActionType.STOP) .setType(GameActionType.STOP)
); );*/
} else { } else {
switch (keyBinding.get(moveQueue[0])) { switch (keyBinding.get(moveQueue[0])) {
case TankAction.MOVE(direction): case TankAction.MOVE(direction):
//ToDo: //ToDo:
//move(direction); move(direction);
Provider.get(IConnection).send( /*Provider.get(IConnection).send(
new GameActionRequest() new GameActionRequest()
.setType(GameActionType.MOVE) .setType(GameActionType.MOVE)
.setDirectionX(direction.x) .setDirectionX(direction.x)
.setDirectionY(direction.y) .setDirectionY(direction.y)
); );*/
case _: case _:
} }
} }

View File

@@ -29,6 +29,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
var persons = Provider.get(GameData).game.persons; var persons = Provider.get(GameData).game.persons;
engine.personId = person.id; engine.personId = person.id;
engine.init(DEFAULT.CONFIG); engine.init(DEFAULT.CONFIG);
engine.initTanks(persons);
content.addEventListener(Event.ENTER_FRAME, updateGame); content.addEventListener(Event.ENTER_FRAME, updateGame);
Provider.get(IConnection).packetHandler.addListener(this); Provider.get(IConnection).packetHandler.addListener(this);
render.draw(engine); render.draw(engine);
@@ -41,8 +42,8 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
} }
private function updateGame(_):Void { private function updateGame(_):Void {
//game.update(); engine.update();
//render.draw(game); render.draw(engine);
} }
public function onGameUpdateResponse(packet:GameUpdateResponse):Void { public function onGameUpdateResponse(packet:GameUpdateResponse):Void {

View File

@@ -0,0 +1,35 @@
package ru.m.tankz.view.frames;
import ru.m.tankz.proto.Person;
import ru.m.tankz.proto.Game;
import haxework.gui.frame.IFrameSwitcher;
import ru.m.tankz.data.GameData;
import haxework.provider.Provider;
import haxework.gui.ButtonView;
import haxework.gui.ViewBuilder;
import haxework.gui.VGroupView;
@:template("layout/frames/start.json", "layout/styles.json")
class StartFrame extends VGroupView implements ViewBuilder {
public static inline var ID = "start";
public function init() {
start_1p.onPress = this;
}
public function onPress(view:ButtonView):Void {
switch (view.id) {
case "start_1p":
var player = new Person();
player.id = 1;
var game = new Game();
game.creator = player;
game.persons.push(player);
game.id = 1;
Provider.get(GameData).person = player;
Provider.get(GameData).game = game;
Provider.get(IFrameSwitcher).change(GameFrame.ID);
}
}
}

View File

@@ -1,4 +1,3 @@
"use strict";
const fs = require('fs'); const fs = require('fs');
const tmp = require('tmp-file'); const tmp = require('tmp-file');
const gutil = require('gulp-util'); const gutil = require('gulp-util');

View File

@@ -1,72 +0,0 @@
"use strict";
const exec = require('./exec');
const fs = require('fs');
const through = require('through2');
const Android = {
adb: (args) => {
const adbBin = `${process.env.ANDROID_HOME}/platform-tools/adb.exe`;
return exec('.', [adbBin].concat(args).join(' ')).then((data) => {
for (let line of data.stderr.split('\n')) {
if (line.indexOf('Error') > -1) {
throw line;
}
}
});
},
aapt: (args) => {
let buildToolsVersion = null;
fs.readdirSync(`${process.env.ANDROID_HOME}/build-tools`).forEach(file => {
buildToolsVersion = file;
});
const aaptBin = `${process.env.ANDROID_HOME}/build-tools/${buildToolsVersion}/aapt.exe`;
return exec('.', [aaptBin].concat(args).join(' '));
},
apk: () => {
return through.obj(function(file, enc, callback) {
Android.aapt(['l', '-a', file.path]).then((data) => {
let activity = false;
for (let line of data.stdout.split('\n')) {
if (line.indexOf('package') > -1) {
const value = /"(.*?)"/.exec(line);
if (value) file.package = value[1]
}
if (line.indexOf('activity') > -1) {
activity = true;
}
if (activity && line.indexOf('name') > -1) {
const value = /"(.*?)"/.exec(line);
if (value) {
file.activity = value[1];
activity = false;
}
}
}
this.push(file);
callback();
});
});
},
install: () => {
return through.obj(function(file, enc, callback) {
Android.adb(['install', '-r', file.path]).then(() => {
this.push(file);
callback();
});
});
},
start: () => {
return through.obj((file, enc, callback) => {
const name = `${file.package}/${file.activity}`;
Android.adb(['shell', 'am', 'start', '-n', name]).then(() => callback());
});
}
};
module.exports = Android;

View File

@@ -1,4 +1,3 @@
"use strict";
const fs = require('fs'); const fs = require('fs');
const os = require('os'); const os = require('os');
const path = require('path'); const path = require('path');

View File

@@ -1,4 +1,3 @@
"use strict";
const os = require('os'); const os = require('os');
const gulp = require('gulp'); const gulp = require('gulp');
const gutil = require('gulp-util'); const gutil = require('gulp-util');

View File

@@ -1,26 +0,0 @@
'use strict';
const through = require('through2');
const gutil = require('gulp-util');
const col = gutil.colors;
const Tail = require('tail').Tail;
module.exports = (handler) => {
let stream = null;
let tail = null;
const bufferContents = (file, enc, callback) => {
tail = new Tail(file.path);
tail.on("line", handler);
callback();
};
const endStream = (callback) => {
if (tail) {
tail.unwatch();
tail = null;
}
callback();
};
return stream = through.obj(bufferContents, endStream);
};