[resources] added dota maps
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ansi-colors": "^1.0.1",
|
"ansi-colors": "^1.0.1",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
game:
|
game:
|
||||||
levels: 3
|
levels: 7
|
||||||
friendlyFire: true
|
friendlyFire: true
|
||||||
|
|
||||||
map:
|
map:
|
||||||
|
|||||||
2
src/client/resources/dota/levels/level003.txt
Normal file
2
src/client/resources/dota/levels/level003.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 24, type: eagle, y: 26}, {index: 0, direction: right, team: radiant, x: 14, type: tank, y: 26}, {index: 1, direction: right, team: radiant, x: 20, type: tank, y: 20}, {index: 2, direction: right, team: radiant, x: 26, type: tank, y: 20}, {index: 3, direction: right, team: radiant, x: 34, type: tank, y: 24}, {index: 4, direction: right, team: radiant, x: 38, type: tank, y: 22}, {index: -1, direction: right, team: dire, x: 22, type: eagle, y: 2}, {index: 0, direction: left, team: dire, x: 8, type: tank, y: 2}, {index: 1, direction: left, team: dire, x: 12, type: tank, y: 6}, {index: 2, direction: left, team: dire, x: 20, type: tank, y: 6}, {index: 3, direction: left, team: dire, x: 21, type: tank, y: 10}, {index: 4, direction: left, team: dire, x: 28, type: tank, y: 4}]
|
||||||
|
data: "444444444400000000440000004444000000000044444444440000000044000000444400000000004444440000004444004400000044440033444400444444000000444400440000004444003344440000000000440000440044000000000000000000000000000044000044004400000000000000000000003344004400000000000044004444440000444400334400440000000000004400444444000044440000000000004400444444440033440000005544000000000000440044444444003344000000554444004433440044444400000000004400440000004400443344004444440000000000440044000000440000000000004444004444440044004444440044000000000000444400444444004400444444000000440055440044440044440000000055444400000044005544004444004444000000005544440000444400444400000000000000443300000000000044440044440000000000000044330000000000000044004444003300444444004444004433004400004400444400330044444400444400443300444400000000000033000000000000000044000000440000000000003300000000000000004400000044440044004444444400444444440000440044004444004400444444440044444444000044004400000000000000440000000000000000000000440000000000000044000000000000000000000044004455003344000000440044000000440033444400445500334400000044004400000044003344440044440000000044000000440000004400000000004444000000004400000044000000440000000000"
|
||||||
2
src/client/resources/dota/levels/level004.txt
Normal file
2
src/client/resources/dota/levels/level004.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 12, type: eagle, y: 2}, {index: 0, direction: right, team: radiant, x: 6, type: tank, y: 6}, {index: 1, direction: right, team: radiant, x: 10, type: tank, y: 10}, {index: 2, direction: right, team: radiant, x: 14, type: tank, y: 10}, {index: 3, direction: right, team: radiant, x: 18, type: tank, y: 6}, {index: 4, direction: right, team: radiant, x: 20, type: tank, y: 2}, {index: -1, direction: right, team: dire, x: 22, type: eagle, y: 26}, {index: 0, direction: left, team: dire, x: 12, type: tank, y: 26}, {index: 1, direction: left, team: dire, x: 18, type: tank, y: 22}, {index: 2, direction: left, team: dire, x: 24, type: tank, y: 22}, {index: 3, direction: left, team: dire, x: 28, type: tank, y: 18}, {index: 4, direction: left, team: dire, x: 30, type: tank, y: 10}]
|
||||||
|
data: "000000000033333300000000000000000000000000000000003333330000000000000000000000000000004400330033004400000000003300000044000000440033003300440000000000330000004400000000003333330000000044440000000000000000000000333333000000004444000000000000000000000000000000003300000000004444000000000000000000000000330000000000444400000044000000004400000000004400000044000000004400000000440000000000440000004400000000000033000000000000004444000000000000000000003300000000000000444400000000000000000000000000330000440000000033000000000000000000000033000044000000003300000000000000000000000000444400004400000000000000000000000000000044440000440000000000000000000000334444004444000000000044000000000000000033444400444400000000004400000000004400000044000000000000330000440000000000440000004400000000000033000044000000000000440000000000330000440000000000000033000044000000000033000044000000000000003300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044000000003333330000000033000000000000004400000000333333000000003300000000000000000000440033003300440000000000000000000000000044003300330044000000000000000000000000000000333333000000000000000000000000000000000033333300000000000000"
|
||||||
2
src/client/resources/dota/levels/level005.txt
Normal file
2
src/client/resources/dota/levels/level005.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 19, type: eagle, y: 28}, {index: 0, direction: right, team: radiant, x: 0, type: tank, y: 28}, {index: 1, direction: right, team: radiant, x: 10, type: tank, y: 22}, {index: 2, direction: right, team: radiant, x: 19, type: tank, y: 18}, {index: 3, direction: right, team: radiant, x: 28, type: tank, y: 22}, {index: 4, direction: right, team: radiant, x: 38, type: tank, y: 28}, {index: -1, direction: right, team: dire, x: 19, type: eagle, y: 0}, {index: 0, direction: left, team: dire, x: 0, type: tank, y: 0}, {index: 1, direction: left, team: dire, x: 10, type: tank, y: 6}, {index: 2, direction: left, team: dire, x: 19, type: tank, y: 10}, {index: 3, direction: left, team: dire, x: 28, type: tank, y: 6}, {index: 4, direction: left, team: dire, x: 38, type: tank, y: 0}]
|
||||||
|
data: "000000000000440000000000004400000000000000000000000044000000000000440000000000004400000000000000000440000000000000000044440000000000000000044000000000000000004400000000005555555555555555555500000000000000000000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004400000000000000000000440000000000000000440000000000000000000044000000005555555544333333333553333333334455555555555555554433333333355333333333445555555500000000440000000000000000000044000000000000000044000000000000000000004400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000550000000000000000000000000000000000000055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055555555555555555555000000000000000000005555555555555555555500000000004400000000000000000440000000000000000044440000000000000000044000000000000000004400000000000044000000000000440000000000000000000000004400000000000044000000000000"
|
||||||
2
src/client/resources/dota/levels/level006.txt
Normal file
2
src/client/resources/dota/levels/level006.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
points: [{index: -1, direction: right, team: radiant, x: 19, type: eagle, y: 28}, {index: 0, direction: right, team: radiant, x: 2, type: tank, y: 22}, {index: 1, direction: right, team: radiant, x: 9, type: tank, y: 20}, {index: 2, direction: right, team: radiant, x: 19, type: tank, y: 24}, {index: 3, direction: right, team: radiant, x: 29, type: tank, y: 20}, {index: 4, direction: right, team: radiant, x: 36, type: tank, y: 22}, {index: -1, direction: right, team: dire, x: 19, type: eagle, y: 0}, {index: 0, direction: left, team: dire, x: 2, type: tank, y: 6}, {index: 1, direction: left, team: dire, x: 9, type: tank, y: 8}, {index: 2, direction: left, team: dire, x: 19, type: tank, y: 4}, {index: 3, direction: left, team: dire, x: 29, type: tank, y: 8}, {index: 4, direction: left, team: dire, x: 36, type: tank, y: 6}]
|
||||||
|
data: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555544444455555555000000000000000000555555554444445555555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005500000000000000550000000000000000000000550000000000000055000000000000000000000055000000000000005500000000000000000000005500000000000000550000000000000000000000000044000000440000000000000000000000000000004400000044000000000000000333333333333333445500004433333333333333333333333333333344550000443333333333333333333333333333334400440044333333333333333333333333333333440044004433333333333333333333333333333344000055443333333333333333333333333333334400005544333333333333333000000000000000440000004400000000000000000000000000000044000000440000000000000000000000000055000000000000005500000000000000000000005500000000000000550000000000000000000000550000000000000055000000000000000000000055000000000000005500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555544444455555555000000000000000000555555554444445555555500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
package ru.m.tankz.bot;
|
package ru.m.tankz.bot;
|
||||||
|
|
||||||
|
import ru.m.tankz.core.Tank;
|
||||||
|
import ru.m.tankz.core.Entity;
|
||||||
|
import ru.m.tankz.core.Eagle;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
import ru.m.tankz.core.EntityType;
|
import ru.m.tankz.core.EntityType;
|
||||||
import ru.m.tankz.control.Control;
|
import ru.m.tankz.control.Control;
|
||||||
@@ -7,11 +10,49 @@ import ru.m.geom.Direction;
|
|||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class BotHelper {
|
||||||
|
|
||||||
|
public static function findEagle(team:TeamId, handler:ControlHandler):Null<Eagle> {
|
||||||
|
for (entity in handler.entities) {
|
||||||
|
switch (EntityTypeResolver.of(entity)) {
|
||||||
|
case EntityType.EAGLE(eagle):
|
||||||
|
if (eagle.team != team) {
|
||||||
|
return eagle;
|
||||||
|
}
|
||||||
|
case x:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDirectionTo(entity:Entity, target:Entity):Direction {
|
||||||
|
var x:Float = target.rect.x - entity.rect.x;
|
||||||
|
var y:Float = target.rect.y - entity.rect.y;
|
||||||
|
var xD:Direction = Direction.from(Std.int(x / Math.abs(x)), 0);
|
||||||
|
var yD:Direction = Direction.from(0, Std.int(y / Math.abs(y)));
|
||||||
|
if (entity.rect.direction == xD) return yD;
|
||||||
|
if (entity.rect.direction == yD) return xD;
|
||||||
|
return Math.abs(x) > Math.abs(y) ? xD : yD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function randomDirection():Direction {
|
||||||
|
return [
|
||||||
|
Direction.TOP,
|
||||||
|
Direction.BOTTOM,
|
||||||
|
Direction.LEFT,
|
||||||
|
Direction.RIGHT,
|
||||||
|
][Math.floor(Math.random() * 4)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class BotControl extends Control {
|
class BotControl extends Control {
|
||||||
|
|
||||||
private var shotTimer:Timer;
|
private var shotTimer:Timer;
|
||||||
private var turnRandomTimer:Timer;
|
private var turnRandomTimer:Timer;
|
||||||
private var turnTimer:Timer;
|
private var turnTimer:Timer;
|
||||||
|
private var tank(get, null):Tank;
|
||||||
|
|
||||||
public function new(playerId:PlayerId) {
|
public function new(playerId:PlayerId) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
@@ -27,7 +68,6 @@ class BotControl extends Control {
|
|||||||
|
|
||||||
override public function start():Void {
|
override public function start():Void {
|
||||||
if (handler == null) return;
|
if (handler == null) return;
|
||||||
var tank = handler.entities.get(tankId);
|
|
||||||
action(TankAction.MOVE(tank.rect.direction));
|
action(TankAction.MOVE(tank.rect.direction));
|
||||||
if (shotTimer == null) {
|
if (shotTimer == null) {
|
||||||
shotTimer = new Timer(1000);
|
shotTimer = new Timer(1000);
|
||||||
@@ -65,15 +105,17 @@ class BotControl extends Control {
|
|||||||
turnTimer.stop();
|
turnTimer.stop();
|
||||||
turnTimer = null;
|
turnTimer = null;
|
||||||
}
|
}
|
||||||
action(TankAction.MOVE(randomDirection()));
|
// ToDo:
|
||||||
|
if (handler == null || tank == null) return;
|
||||||
|
var eagle:Eagle = BotHelper.findEagle(playerId.team, handler);
|
||||||
|
if (eagle != null && Math.random() > 0.25) {
|
||||||
|
action(TankAction.MOVE(BotHelper.getDirectionTo(tank, eagle)));
|
||||||
|
} else {
|
||||||
|
action(TankAction.MOVE(BotHelper.randomDirection()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function randomDirection():Direction {
|
private function get_tank():Tank {
|
||||||
return [
|
return cast handler.entities[tankId];
|
||||||
Direction.TOP,
|
|
||||||
Direction.BOTTOM,
|
|
||||||
Direction.LEFT,
|
|
||||||
Direction.RIGHT,
|
|
||||||
][Math.floor(Math.random() * 4)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user