[client] add font
This commit is contained in:
@@ -19,7 +19,7 @@ class HardBotControl extends BotControl {
|
||||
shot();
|
||||
}
|
||||
case CELL(cell):
|
||||
if (cell.layer == 2 && cell.armor <= tank.config.bullet.piercing) {
|
||||
if (cell.layer == 2 && cell.armor > -1 && cell.armor <= tank.config.bullet.piercing) {
|
||||
shot();
|
||||
}
|
||||
case EAGLE(eagle):
|
||||
@@ -32,6 +32,7 @@ class HardBotControl extends BotControl {
|
||||
}
|
||||
|
||||
override public function start():Void {
|
||||
super.start();
|
||||
if (handler == null) return;
|
||||
turn(tank.rect.direction);
|
||||
if (actionTimer == null) {
|
||||
@@ -49,6 +50,9 @@ class HardBotControl extends BotControl {
|
||||
}
|
||||
|
||||
private function nextAction():Void {
|
||||
if (tank == null) {
|
||||
return; //ToDo: stop?
|
||||
}
|
||||
var enemy:Tank = null;
|
||||
var distance:Float = Math.POSITIVE_INFINITY;
|
||||
for (entity in handler.entities.iterator()) {
|
||||
@@ -68,8 +72,9 @@ class HardBotControl extends BotControl {
|
||||
var d = BotHelper.getDirectionTo(tank, enemy);
|
||||
if (d != tank.rect.direction) {
|
||||
turn(BotHelper.getDirectionTo(tank, enemy), 1);
|
||||
} else {
|
||||
shot();
|
||||
}
|
||||
shot();
|
||||
} else if (Math.random() > 0.8) {
|
||||
calcTurn();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.core;
|
||||
|
||||
import haxe.Timer;
|
||||
import haxework.color.Color;
|
||||
import ru.m.geom.Direction;
|
||||
import ru.m.geom.Point;
|
||||
@@ -18,6 +19,7 @@ class Tank extends MobileEntity {
|
||||
public var freezing(default, null):Modificator;
|
||||
|
||||
private var bulletsCounter:Int = 0;
|
||||
private var shotDelayTimer:Timer;
|
||||
|
||||
public function new(playerId:PlayerId, config:TankConfig) {
|
||||
super(new Rectangle(0, 0, config.width, config.height), config.speed, Direction.RIGHT);
|
||||
@@ -45,12 +47,18 @@ class Tank extends MobileEntity {
|
||||
}
|
||||
|
||||
public function shot():Null<Bullet> {
|
||||
if (freezing.active) return null;
|
||||
if (bulletsCounter >= config.bullets) return null;
|
||||
if (
|
||||
freezing.active ||
|
||||
bulletsCounter >= config.bullets ||
|
||||
shotDelayTimer != null
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
var bullet = new Bullet(this);
|
||||
bullet.rect.center = rect.center.add(new Point(rect.width / 4 * rect.direction.x, rect.height / 4 * rect.direction.y));
|
||||
bullet.move(rect.direction);
|
||||
bulletsCounter++;
|
||||
shotDelayTimer = Timer.delay(function() shotDelayTimer = null, 200);
|
||||
return bullet;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user