update
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import flash.text.Font;
|
||||
import ru.m.tankz.view.frames.StartFrame;
|
||||
import haxework.log.SocketLogger;
|
||||
import haxework.resources.Resources;
|
||||
import haxework.resources.IResources;
|
||||
@@ -49,9 +51,8 @@ class Client implements IConnectionHandler {
|
||||
Provider.setFactory(IResources, Resources);
|
||||
Provider.setFactory(GameData, GameData);
|
||||
|
||||
//var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF");
|
||||
//Provider.get(IResources).text.put("fontName", font.fontName);
|
||||
Provider.get(IResources).text.put("fontName", "Arial");
|
||||
var font:Font = Font.enumerateFonts()[0];
|
||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
||||
|
||||
Provider.set(IPacketBuilder, new PacketBuilder());
|
||||
#if flash
|
||||
@@ -66,7 +67,7 @@ class Client implements IConnectionHandler {
|
||||
Provider.set(IFrameSwitcher, view.switcher);
|
||||
Root.bind(view);
|
||||
view.logout.onPress = this;
|
||||
view.switcher.change(AuthFrame.ID);
|
||||
view.switcher.change(StartFrame.ID);
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
|
||||
@@ -30,11 +30,11 @@ class PlayerTank extends Tank {
|
||||
}
|
||||
case TankAction.SHOT:
|
||||
//ToDo:
|
||||
//shot();
|
||||
Provider.get(IConnection).send(
|
||||
shot();
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.SHOT)
|
||||
);
|
||||
);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,22 +49,22 @@ class PlayerTank extends Tank {
|
||||
|
||||
private function updateMove():Void {
|
||||
if (moveQueue.length == 0) {
|
||||
//stop();
|
||||
Provider.get(IConnection).send(
|
||||
stop();
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.STOP)
|
||||
);
|
||||
);*/
|
||||
} else {
|
||||
switch (keyBinding.get(moveQueue[0])) {
|
||||
case TankAction.MOVE(direction):
|
||||
//ToDo:
|
||||
//move(direction);
|
||||
Provider.get(IConnection).send(
|
||||
move(direction);
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.MOVE)
|
||||
.setDirectionX(direction.x)
|
||||
.setDirectionY(direction.y)
|
||||
);
|
||||
);*/
|
||||
case _:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
var persons = Provider.get(GameData).game.persons;
|
||||
engine.personId = person.id;
|
||||
engine.init(DEFAULT.CONFIG);
|
||||
engine.initTanks(persons);
|
||||
content.addEventListener(Event.ENTER_FRAME, updateGame);
|
||||
Provider.get(IConnection).packetHandler.addListener(this);
|
||||
render.draw(engine);
|
||||
@@ -41,8 +42,8 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
}
|
||||
|
||||
private function updateGame(_):Void {
|
||||
//game.update();
|
||||
//render.draw(game);
|
||||
engine.update();
|
||||
render.draw(engine);
|
||||
}
|
||||
|
||||
public function onGameUpdateResponse(packet:GameUpdateResponse):Void {
|
||||
|
||||
35
src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx
Normal file
35
src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user