This commit is contained in:
2015-08-12 15:19:34 +03:00
parent 64e1cfdbfc
commit 64d36c6924
14 changed files with 314 additions and 30 deletions

View File

@@ -42,11 +42,11 @@ class BaseConnection implements IConnection {
}
}
public function send(packet:Message):Void {
L.d("Send", Type.getClassName(Type.getClass(packet)).split(".").pop());
//L.d("Send", Type.getClassName(Type.getClass(packet)).split(".").pop());
}
public function receive(packet:Message):Void {
L.d("Receive", Type.getClassName(Type.getClass(packet)).split(".").pop());
//L.d("Receive", Type.getClassName(Type.getClass(packet)).split(".").pop());
var name = "on" + Type.getClassName(Type.getClass(packet)).split(".").pop();
packetHandler.dispatch(function(h) {
var method = Reflect.field(h, name);

View File

@@ -17,7 +17,7 @@ class NekoWebConnection extends NekoConnection {
}
override public function send(packet:Message):Void {
L.d("Send", Type.getClassName(Type.getClass(packet)).split(".").pop());
//L.d("Send", Type.getClassName(Type.getClass(packet)).split(".").pop());
try {
var data = WebSocketTools.packet2string(packet, builder);
writeData(data, socket);

View File

@@ -2,8 +2,8 @@ package ru.m.tankz.core;
class Entity implements IEntity {
public var x(default, default):Float;
public var y(default, default):Float;
public var x(default, default):Float = 0;
public var y(default, default):Float = 0;
public var width(default, default):Float;
public var height(default, default):Float;

View File

@@ -1,6 +1,8 @@
package ru.m.tankz.core;
interface IMobileEntity extends IEntity {
public var id(default, null):Int;
public var mx(default, default):Float;
public var my(default, default):Float;

View File

@@ -1,7 +1,6 @@
package ru.m.tankz.core;
interface ITank extends IMobileEntity {
public var id(default, null):Int;
public var bullets:Array<IMobileEntity>;
public function shot():Void;

View File

@@ -1,15 +1,17 @@
package ru.m.tankz.core;
class MobileEntity extends Entity implements IMobileEntity {
public var id(default, null):Int;
public var mx(default, default):Float;
public var my(default, default):Float;
public var mx(default, default):Float = 0;
public var my(default, default):Float = 0;
public var speed(default, null):Float;
public var speed(default, null):Float = 0;
public var direction(default, default):Direction;
public function new(x:Float, y:Float, speed:Float, direction:Direction = null) {
public function new(id:Int, x:Float, y:Float, speed:Float, direction:Direction = null) {
super(x, y);
this.id = id;
this.speed = speed;
this.direction = direction == null ? Direction.BOTTOM : direction;
}

View File

@@ -7,11 +7,10 @@ enum TankAction {
class Tank extends MobileEntity implements ITank {
public var id(default, null):Int;
public var bullets:Array<IMobileEntity>;
public function new(id:Int, x:Float, y:Float) {
super(x, y, 4);
super(id, x, y, 4);
this.id = id;
bullets = new Array<IMobileEntity>();
width = 34;
@@ -20,7 +19,7 @@ class Tank extends MobileEntity implements ITank {
public function shot():Void {
if (bullets.length >= 5) return;
var bullet = new MobileEntity(x + width / 2 - 5, y + height / 2 - 5, 6, direction);
var bullet = new MobileEntity(0, x + width / 2 - 5, y + height / 2 - 5, 6, direction);
bullet.width = 10;
bullet.height = 10;
bullet.move(direction);