[client] add font
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.8.5",
|
"version": "0.8.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import haxework.gui.popup.PopupManager;
|
||||||
import ru.m.tankz.storage.SettingsStorage;
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
import haxework.provider.Provider;
|
import haxework.provider.Provider;
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
@@ -49,6 +50,7 @@ class Init {
|
|||||||
Provider.setFactory(SoundManager, SoundManager);
|
Provider.setFactory(SoundManager, SoundManager);
|
||||||
Provider.setFactory(NetworkManager, NetworkManager);
|
Provider.setFactory(NetworkManager, NetworkManager);
|
||||||
Provider.setFactory(IControlFactory, ClientControlFactory);
|
Provider.setFactory(IControlFactory, ClientControlFactory);
|
||||||
|
Provider.setFactory(PopupManager, PopupManager);
|
||||||
|
|
||||||
var host:String = getHost();
|
var host:String = getHost();
|
||||||
L.d('Init', 'host: ${host}');
|
L.d('Init', 'host: ${host}');
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.text.Font;
|
||||||
|
import flash.text.FontType;
|
||||||
import haxework.color.ColorUtil;
|
import haxework.color.ColorUtil;
|
||||||
import haxework.gui.core.Geometry;
|
import haxework.gui.core.Geometry;
|
||||||
import haxework.gui.core.HAlign;
|
import haxework.gui.core.HAlign;
|
||||||
import haxework.gui.core.VAlign;
|
import haxework.gui.core.VAlign;
|
||||||
|
import haxework.gui.ITextView;
|
||||||
import haxework.gui.layout.Layout;
|
import haxework.gui.layout.Layout;
|
||||||
|
import haxework.gui.skin.ISkin;
|
||||||
import haxework.gui.skin.Skin;
|
import haxework.gui.skin.Skin;
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
@@ -17,9 +21,32 @@ class Style {
|
|||||||
private static var lightColor = 0x95937D;
|
private static var lightColor = 0x95937D;
|
||||||
private static var darkColor = 0x777564;
|
private static var darkColor = 0x777564;
|
||||||
private static var textColor = 0xE7E0BB;
|
private static var textColor = 0xE7E0BB;
|
||||||
private static var fontFamily = "Courirer New";
|
|
||||||
|
|
||||||
public static function register() {
|
private static var baseFontSize = 18;
|
||||||
|
private static var bigFontSize = 22;
|
||||||
|
private static var veryBigFontSize = 24;
|
||||||
|
|
||||||
|
private static var fontFamily = "Courirer New";
|
||||||
|
private static var fontEmbed = false;
|
||||||
|
|
||||||
|
public static function text(color):ISkin<ITextView> {
|
||||||
|
return Skin.text(color, baseFontSize, fontFamily, fontEmbed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function register(font:Font = null) {
|
||||||
|
resources.color.put("light", lightColor);
|
||||||
|
resources.color.put("dark", darkColor);
|
||||||
|
if (font == null) {
|
||||||
|
font = Font.enumerateFonts()[0];
|
||||||
|
}
|
||||||
|
if (font == null) {
|
||||||
|
font = Font.enumerateFonts(true)[0];
|
||||||
|
}
|
||||||
|
fontFamily = font == null ? "Courirer New" : font.fontName;
|
||||||
|
fontEmbed = font == null ? false : switch font.fontType {
|
||||||
|
case DEVICE: false;
|
||||||
|
case _: true;
|
||||||
|
};
|
||||||
resources.skin.put("light", [
|
resources.skin.put("light", [
|
||||||
Skin.color(lightColor),
|
Skin.color(lightColor),
|
||||||
]);
|
]);
|
||||||
@@ -27,45 +54,48 @@ class Style {
|
|||||||
Skin.color(darkColor),
|
Skin.color(darkColor),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("text", [
|
resources.skin.put("text", [
|
||||||
Skin.text(textColor, 16, fontFamily),
|
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
||||||
|
]);
|
||||||
|
resources.skin.put("scroll.vertical", [
|
||||||
|
haxework.gui.skin.Skin.scrollVertical(lightColor, darkColor),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("text.header", [
|
resources.skin.put("text.header", [
|
||||||
Skin.color(0x000000, 0.1),
|
Skin.color(0x000000, 0.1),
|
||||||
Skin.border(lightColor, 1, 2),
|
Skin.border(lightColor, 1, 2),
|
||||||
Skin.text(textColor, 22, fontFamily),
|
Skin.text(textColor, bigFontSize, fontFamily, fontEmbed),
|
||||||
Skin.geometry(new Geometry().setSize(200, 38).setMargin([0, 0, 0, 30])),
|
Skin.geometry(new Geometry().setPadding([50, 8]).setMargin([0, 0, 0, 30])),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("button", [
|
resources.skin.put("button", [
|
||||||
Skin.buttonColor(lightColor),
|
Skin.buttonColor(lightColor),
|
||||||
Skin.text(textColor, 18, fontFamily),
|
Skin.text(textColor, bigFontSize, fontFamily, fontEmbed),
|
||||||
Skin.size(250, 50),
|
Skin.size(250, 50),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("text.box", [
|
resources.skin.put("text.box", [
|
||||||
Skin.color(0x000000, 0.1),
|
Skin.color(0x000000, 0.1),
|
||||||
Skin.border(lightColor, 1, 2),
|
Skin.border(lightColor, 1, 2),
|
||||||
Skin.text(textColor, 16, fontFamily),
|
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("text.box.active", [
|
resources.skin.put("text.box.active", [
|
||||||
Skin.color(0x55aa55),
|
Skin.color(0x55aa55),
|
||||||
Skin.border(0x88dd88, 1, 2),
|
Skin.border(0x88dd88, 1, 2),
|
||||||
Skin.text(textColor, 16, fontFamily),
|
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("button.simple", [
|
resources.skin.put("button.simple", [
|
||||||
Skin.buttonColor(lightColor),
|
Skin.buttonColor(lightColor),
|
||||||
Skin.text(textColor, 16, fontFamily),
|
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
||||||
Skin.size(100, 38),
|
Skin.geometry(new Geometry().setPadding([25, 8])),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("button.tab", [
|
resources.skin.put("button.tab", [
|
||||||
Skin.tabColor(lightColor),
|
Skin.tabColor(lightColor),
|
||||||
Skin.text(textColor, 16, fontFamily),
|
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
||||||
Skin.size(200, 38),
|
Skin.geometry(new Geometry().setPadding([25, 8])),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("border", [
|
resources.skin.put("border", [
|
||||||
Skin.border(ColorUtil.multiply(lightColor, 1.5), 1, 2),
|
Skin.border(ColorUtil.multiply(lightColor, 1.5), 1, 2),
|
||||||
]);
|
]);
|
||||||
resources.skin.put("button.level", [
|
resources.skin.put("button.level", [
|
||||||
Skin.buttonColor(lightColor),
|
Skin.buttonColor(lightColor),
|
||||||
Skin.text(textColor, 24, fontFamily),
|
Skin.text(textColor, veryBigFontSize, fontFamily, fontEmbed),
|
||||||
Skin.size(64, 64),
|
Skin.size(64, 64),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,13 @@ import haxework.gui.frame.FrameSwitcher;
|
|||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
|
|
||||||
@:template class ClientView extends FrameSwitcher {
|
@:template class ClientView extends FrameSwitcher {
|
||||||
private static inline var TAG = 'Tankz';
|
|
||||||
|
|
||||||
@:provide var resources:IResources;
|
@:provide var resources:IResources;
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
|
|
||||||
public function init():Void {
|
public function init():Void {
|
||||||
var font:Font = Font.enumerateFonts()[0];
|
var font:Font = Font.enumerateFonts()[0];
|
||||||
resources.text.put('font', 'Bookman Old Style');
|
resources.text.put('version', '${Const.VERSION}');
|
||||||
resources.text.put('version', 'v${Const.VERSION} (${Const.BUILD})');
|
|
||||||
switcher = this;
|
switcher = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import ru.m.tankz.preset.DotaGame;
|
|||||||
case HUMAN(_): true;
|
case HUMAN(_): true;
|
||||||
case _: false;
|
case _: false;
|
||||||
});
|
});
|
||||||
levelLabel.text = 'Level: ${resultState.level}';
|
levelLabel.text = 'Level ${resultState.level}';
|
||||||
nextButton.visible = state != null;
|
nextButton.visible = state != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import ru.m.tankz.view.classic.ClassicLevelFrame;
|
|
||||||
import ru.m.tankz.view.dota.DotaLevelFrame;
|
|
||||||
import haxework.gui.ButtonView;
|
import haxework.gui.ButtonView;
|
||||||
import haxework.gui.frame.FrameSwitcher;
|
import haxework.gui.frame.FrameSwitcher;
|
||||||
import haxework.gui.VGroupView;
|
import haxework.gui.VGroupView;
|
||||||
|
import ru.m.tankz.view.classic.ClassicLevelFrame;
|
||||||
|
import ru.m.tankz.view.dota.DotaLevelFrame;
|
||||||
|
import ru.m.tankz.view.popup.FontPopup;
|
||||||
|
|
||||||
@:template class StartFrame extends VGroupView {
|
@:template class StartFrame extends VGroupView {
|
||||||
|
|
||||||
@@ -12,7 +13,9 @@ import haxework.gui.VGroupView;
|
|||||||
|
|
||||||
@:provide var frameSwitcher:FrameSwitcher;
|
@:provide var frameSwitcher:FrameSwitcher;
|
||||||
|
|
||||||
public function onPress(view:ButtonView):Void {
|
private var fontPopup:FontPopup;
|
||||||
|
|
||||||
|
private function onPress(view:ButtonView):Void {
|
||||||
switch (view.id) {
|
switch (view.id) {
|
||||||
case 'classic':
|
case 'classic':
|
||||||
frameSwitcher.change(ClassicLevelFrame.ID);
|
frameSwitcher.change(ClassicLevelFrame.ID);
|
||||||
@@ -24,4 +27,14 @@ import haxework.gui.VGroupView;
|
|||||||
frameSwitcher.change(SettingsFrame.ID);
|
frameSwitcher.change(SettingsFrame.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function choiceFont():Void {
|
||||||
|
if (fontPopup == null) {
|
||||||
|
fontPopup = new FontPopup();
|
||||||
|
}
|
||||||
|
fontPopup
|
||||||
|
.show()
|
||||||
|
.then(function(font) Style.register(font))
|
||||||
|
.catchError(function(e) {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,17 @@ views:
|
|||||||
skinId: button
|
skinId: button
|
||||||
+onPress: $this:onPress
|
+onPress: $this:onPress
|
||||||
text: DotA
|
text: DotA
|
||||||
- id: network
|
# - id: font
|
||||||
$type: haxework.gui.ButtonView
|
# $type: haxework.gui.ButtonView
|
||||||
skinId: button
|
# skinId: button
|
||||||
+onPress: $this:onPress
|
# +onPress: $code:choiceFont()
|
||||||
text: Network (in developing)
|
# text: Font
|
||||||
fontColor: 0xff0000
|
# - id: network
|
||||||
visible: false
|
# $type: haxework.gui.ButtonView
|
||||||
|
# skinId: button
|
||||||
|
# +onPress: $this:onPress
|
||||||
|
# text: Network (in developing)
|
||||||
|
# fontColor: 0xff0000
|
||||||
- $type: haxework.gui.HGroupView
|
- $type: haxework.gui.HGroupView
|
||||||
skinId: panel
|
skinId: panel
|
||||||
views:
|
views:
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import ru.m.tankz.preset.ClassicGame;
|
|||||||
public var game:Game;
|
public var game:Game;
|
||||||
|
|
||||||
private function updateViews():Void {
|
private function updateViews():Void {
|
||||||
level.text = 'Level: ${game.state.level}';
|
level.text = 'Level ${game.state.level}';
|
||||||
bot.live = game.teams[ClassicGame.BOT].life;
|
bot.live = game.teams[ClassicGame.BOT].life;
|
||||||
player1.live = game.teams[ClassicGame.HUMAN].players[0].state.life;
|
player1.live = game.teams[ClassicGame.HUMAN].players[0].state.life;
|
||||||
player1.score = game.teams[ClassicGame.HUMAN].players[0].state.score;
|
player1.score = game.teams[ClassicGame.HUMAN].players[0].state.score;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import haxework.gui.HGroupView;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private inline function set_live(value:Int):Int {
|
private inline function set_live(value:Int):Int {
|
||||||
liveLabel.text = 'x${value}';
|
liveLabel.text = '${value}';
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ru.m.tankz.view.common;
|
package ru.m.tankz.view.common;
|
||||||
|
|
||||||
|
import haxework.resources.IResources;
|
||||||
import haxework.color.ColorUtil;
|
import haxework.color.ColorUtil;
|
||||||
import haxework.gui.DataView;
|
import haxework.gui.DataView;
|
||||||
import haxework.gui.HGroupView;
|
import haxework.gui.HGroupView;
|
||||||
@@ -24,6 +25,8 @@ class TeamButton extends ToggleButtonView {
|
|||||||
|
|
||||||
class TeamSkin implements ISkin<TeamButton> {
|
class TeamSkin implements ISkin<TeamButton> {
|
||||||
|
|
||||||
|
@:provide private static var resources:IResources;
|
||||||
|
|
||||||
public var color(default, default):Int;
|
public var color(default, default):Int;
|
||||||
|
|
||||||
public function new(color:Int) {
|
public function new(color:Int) {
|
||||||
@@ -31,11 +34,11 @@ class TeamSkin implements ISkin<TeamButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function draw(view:TeamButton):Void {
|
public function draw(view:TeamButton):Void {
|
||||||
view.fontColor = view.on ? 0x000000 : 0xcccccc;
|
view.fontColor = view.on ? 0xffffff : resources.color.get("dark");
|
||||||
var graphics = view.content.graphics;
|
var graphics = view.content.graphics;
|
||||||
graphics.beginFill(view.on ? color : 0x333333);
|
graphics.beginFill(view.on ? color : resources.color.get("light"));
|
||||||
graphics.lineStyle(1, view.on ? 0x333333 : color);
|
graphics.lineStyle(2, color, 0.5);
|
||||||
graphics.drawRect(0, 0, view.width, view.height);
|
graphics.drawRoundRect(0, 0, view.width, view.height, 5, 5);
|
||||||
graphics.endFill();
|
graphics.endFill();
|
||||||
graphics.lineStyle();
|
graphics.lineStyle();
|
||||||
}
|
}
|
||||||
@@ -56,7 +59,8 @@ class TeamSkin implements ISkin<TeamButton> {
|
|||||||
|
|
||||||
private function teamViewFactory(index:Int, team:TeamId) {
|
private function teamViewFactory(index:Int, team:TeamId) {
|
||||||
var view = new TeamButton();
|
var view = new TeamButton();
|
||||||
view.skin = [new TeamSkin(getTeamColor(team))];
|
var color = getTeamColor(team);
|
||||||
|
view.skin = [Style.text(color), new TeamSkin(color)];
|
||||||
view.geometry.padding = [10, 5];
|
view.geometry.padding = [10, 5];
|
||||||
view.team = team;
|
view.team = team;
|
||||||
view.on = team == TEAM_NONE;
|
view.on = team == TEAM_NONE;
|
||||||
@@ -70,7 +74,7 @@ class TeamSkin implements ISkin<TeamButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function getTeamColor(teamId:TeamId):Int {
|
private function getTeamColor(teamId:TeamId):Int {
|
||||||
var color = 0xcccccc;
|
var color = 0xaaaaaa;
|
||||||
for (team in state.preset.teams) {
|
for (team in state.preset.teams) {
|
||||||
if (team.id == teamId) {
|
if (team.id == teamId) {
|
||||||
if (!team.color.zero) color = team.color;
|
if (!team.color.zero) color = team.color;
|
||||||
@@ -82,7 +86,7 @@ class TeamSkin implements ISkin<TeamButton> {
|
|||||||
|
|
||||||
private function set_item_index(value:Int):Int {
|
private function set_item_index(value:Int):Int {
|
||||||
item_index = value;
|
item_index = value;
|
||||||
label.text = 'Player ${item_index}';
|
label.text = 'Player ${item_index+1}';
|
||||||
return item_index;
|
return item_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import ru.m.tankz.preset.DotaGame;
|
|||||||
public var game:Game;
|
public var game:Game;
|
||||||
|
|
||||||
private function updateViews():Void {
|
private function updateViews():Void {
|
||||||
level.text = 'Level: ${game.state.level}';
|
level.text = 'Level ${game.state.level}';
|
||||||
radiant.live = game.teams[DotaGame.RADIANT].life;
|
radiant.live = game.teams[DotaGame.RADIANT].life;
|
||||||
radiant.score = game.teams[DotaGame.RADIANT].score;
|
radiant.score = game.teams[DotaGame.RADIANT].score;
|
||||||
dire.live = game.teams[DotaGame.DIRE].life;
|
dire.live = game.teams[DotaGame.DIRE].life;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ views:
|
|||||||
$type: haxework.gui.DataView
|
$type: haxework.gui.DataView
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.gui.layout.VerticalLayout
|
$type: haxework.gui.layout.VerticalLayout
|
||||||
hAlign: center
|
hAlign: right
|
||||||
factory: $this:playerViewFactory
|
factory: $this:playerViewFactory
|
||||||
geometry.padding: 10
|
geometry.padding: 10
|
||||||
- id: levels
|
- id: levels
|
||||||
|
|||||||
41
src/client/haxe/ru/m/tankz/view/popup/FontPopup.hx
Normal file
41
src/client/haxe/ru/m/tankz/view/popup/FontPopup.hx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package ru.m.tankz.view.popup;
|
||||||
|
|
||||||
|
import flash.text.Font;
|
||||||
|
import flash.text.FontType;
|
||||||
|
import haxework.gui.list.LabelListItem;
|
||||||
|
import haxework.gui.list.ListView;
|
||||||
|
import haxework.gui.popup.PopupView;
|
||||||
|
|
||||||
|
class FontLabelView extends LabelListItem<Font> {
|
||||||
|
|
||||||
|
override private function set_data(value:Font):Font {
|
||||||
|
skinId = item_index % 2 == 0 ? "light" : "dark";
|
||||||
|
data = value;
|
||||||
|
text = value.fontName;
|
||||||
|
fontFamily = value.fontName;
|
||||||
|
fontEmbed = switch value.fontType {
|
||||||
|
case DEVICE: false;
|
||||||
|
case _: true;
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@:template class FontPopup extends PopupView<Font> {
|
||||||
|
|
||||||
|
@:view var fonts:ListView<Font>;
|
||||||
|
|
||||||
|
private function init():Void {
|
||||||
|
var values = Font.enumerateFonts(true);
|
||||||
|
values.sort(function(a:Font, b:Font) {
|
||||||
|
return switch [a.fontType, b.fontType] {
|
||||||
|
case [FontType.DEVICE, _]: 1;
|
||||||
|
case [_, FontType.DEVICE]: -1;
|
||||||
|
case _: 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fonts.data = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fontViewFactory() return new FontLabelView();
|
||||||
|
}
|
||||||
27
src/client/haxe/ru/m/tankz/view/popup/FontPopup.yaml
Normal file
27
src/client/haxe/ru/m/tankz/view/popup/FontPopup.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
view:
|
||||||
|
$type: haxework.gui.VGroupView
|
||||||
|
geometry.size.width: 400
|
||||||
|
geometry.size.height: 80%
|
||||||
|
geometry.padding: 10
|
||||||
|
geometry.hAlign: center
|
||||||
|
geometry.vAlign: middle
|
||||||
|
skinId: dark
|
||||||
|
views:
|
||||||
|
- id: fonts
|
||||||
|
$type: haxework.gui.list.VListView
|
||||||
|
geometry.size.stretch: true
|
||||||
|
factory: $this:fontViewFactory
|
||||||
|
+onItemSelect: $code:function(item) close(item.data)
|
||||||
|
scroll:
|
||||||
|
$type: haxework.gui.list.VScrollBarView
|
||||||
|
skinId: scroll.vertical
|
||||||
|
- $type: haxework.gui.HGroupView
|
||||||
|
geometry.size.width: 100%
|
||||||
|
geometry.margin.top: 10
|
||||||
|
layout.hAlign: right
|
||||||
|
views:
|
||||||
|
- $type: haxework.gui.ButtonView
|
||||||
|
skinId: button.simple
|
||||||
|
text: Cancel
|
||||||
|
+onPress: $code:reject('cancel')
|
||||||
@@ -30,7 +30,7 @@ class KeyboardMap {
|
|||||||
|
|
||||||
public static function getName(key: Int): String {
|
public static function getName(key: Int): String {
|
||||||
if (instance == null) instance = new KeyboardMap();
|
if (instance == null) instance = new KeyboardMap();
|
||||||
return key == -1 ? "<NONE>" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key);
|
return key == -1 ? "(NONE)" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,188 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<animations>
|
|
||||||
<!-- Бонусы -->
|
|
||||||
<animation id="bonus_0">
|
|
||||||
<frame id="bonus_0-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bonus_1">
|
|
||||||
<frame id="bonus_1-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bonus_2">
|
|
||||||
<frame id="bonus_2-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bonus_3">
|
|
||||||
<frame id="bonus_3-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bonus_4">
|
|
||||||
<frame id="bonus_4-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bonus_5">
|
|
||||||
<frame id="bonus_5-0" duration="15"/>
|
|
||||||
<frame id="bonus_0-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Снаряды -->
|
|
||||||
<animation id="bullet_0">
|
|
||||||
<frame id="bullet_0" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="bullet_1">
|
|
||||||
<frame id="bullet_1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Взрыв снаряда -->
|
|
||||||
<animation id="boom">
|
|
||||||
<frame id="boom-0" duration="1"/>
|
|
||||||
<frame id="boom-1" duration="2"/>
|
|
||||||
<frame id="boom-0" duration="2"/>
|
|
||||||
<frame id="boom-1" duration="1"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Орёл -->
|
|
||||||
<animation id="eagle">
|
|
||||||
<frame id="eagle-0" duration="15"/>
|
|
||||||
<frame id="eagle-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Карта -->
|
|
||||||
<animation id="map_0">
|
|
||||||
<frame id="map_0" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="map_1">
|
|
||||||
<frame id="map_1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="map_2">
|
|
||||||
<frame id="map_2" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="map_3">
|
|
||||||
<frame id="map_3-0" duration="15"/>
|
|
||||||
<frame id="map_3-1" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="map_4">
|
|
||||||
<frame id="map_4" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="map_5">
|
|
||||||
<frame id="map_5" duration="15"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Вспышка -->
|
|
||||||
<animation id="appear">
|
|
||||||
<frame id="appear-0" duration="1"/>
|
|
||||||
<frame id="appear-1" duration="1"/>
|
|
||||||
<frame id="appear-2" duration="1"/>
|
|
||||||
<frame id="appear-3" duration="2"/>
|
|
||||||
<frame id="appear-4" duration="1"/>
|
|
||||||
<frame id="appear-5" duration="2"/>
|
|
||||||
<frame id="appear-6" duration="1"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Взрыв -->
|
|
||||||
<animation id="kaboom">
|
|
||||||
<frame id="kaboom-0" duration="1"/>
|
|
||||||
<frame id="kaboom-1" duration="1"/>
|
|
||||||
<frame id="kaboom-2" duration="1"/>
|
|
||||||
<frame id="kaboom-3" duration="1"/>
|
|
||||||
<frame id="kaboom-4" duration="3"/>
|
|
||||||
<frame id="kaboom-1" duration="1"/>
|
|
||||||
<frame id="kaboom-4" duration="2"/>
|
|
||||||
<frame id="kaboom-7" duration="2"/>
|
|
||||||
<frame id="kaboom-8" duration="1"/>
|
|
||||||
<frame id="kaboom-9" duration="2"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Защита -->
|
|
||||||
<animation id="protect">
|
|
||||||
<frame id="protect-0" duration="5"/>
|
|
||||||
<frame id="protect-1" duration="5"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Танки (ботов) -->
|
|
||||||
<animation id="tank_b0_0">
|
|
||||||
<frame id="tank_b0_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b0_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b0_7">
|
|
||||||
<frame id="tank_b0_0-2" duration="3"/>
|
|
||||||
<frame id="tank_b0_0-3" duration="3"/>
|
|
||||||
<frame id="tank_b0_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b0_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
|
|
||||||
<animation id="tank_b1_0">
|
|
||||||
<frame id="tank_b1_0-0" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-1" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-2" duration="2"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b1_7">
|
|
||||||
<frame id="tank_b1_0-3" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-4" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-5" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-0" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-1" duration="2"/>
|
|
||||||
<frame id="tank_b1_0-2" duration="2"/>
|
|
||||||
</animation>
|
|
||||||
|
|
||||||
<animation id="tank_b2_0">
|
|
||||||
<frame id="tank_b2_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b2_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b2_7">
|
|
||||||
<frame id="tank_b2_0-2" duration="3"/>
|
|
||||||
<frame id="tank_b2_0-3" duration="3"/>
|
|
||||||
<frame id="tank_b2_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b2_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
|
|
||||||
<animation id="tank_b3_0">
|
|
||||||
<frame id="tank_b3_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b3_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b3_1">
|
|
||||||
<frame id="tank_b3_1-0" duration="3"/>
|
|
||||||
<frame id="tank_b3_1-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b3_2">
|
|
||||||
<frame id="tank_b3_2-0" duration="3"/>
|
|
||||||
<frame id="tank_b3_2-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b3_3">
|
|
||||||
<frame id="tank_b3_3-0" duration="3"/>
|
|
||||||
<frame id="tank_b3_3-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_b3_7">
|
|
||||||
<frame id="tank_b3_0-2" duration="3"/>
|
|
||||||
<frame id="tank_b3_0-3" duration="3"/>
|
|
||||||
<frame id="tank_b3_0-0" duration="3"/>
|
|
||||||
<frame id="tank_b3_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<!-- Танки (игроков) -->
|
|
||||||
<animation id="tank_p0_0">
|
|
||||||
<frame id="tank_p0_0-0" duration="3"/>
|
|
||||||
<frame id="tank_p0_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p1_0">
|
|
||||||
<frame id="tank_p1_0-0" duration="3"/>
|
|
||||||
<frame id="tank_p1_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p2_0">
|
|
||||||
<frame id="tank_p2_0-0" duration="3"/>
|
|
||||||
<frame id="tank_p2_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p3_0">
|
|
||||||
<frame id="tank_p3_0-0" duration="3"/>
|
|
||||||
<frame id="tank_p3_0-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
|
|
||||||
<animation id="tank_p0_1">
|
|
||||||
<frame id="tank_p0_1-0" duration="3"/>
|
|
||||||
<frame id="tank_p0_1-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p1_1">
|
|
||||||
<frame id="tank_p1_1-0" duration="3"/>
|
|
||||||
<frame id="tank_p1_1-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p2_1">
|
|
||||||
<frame id="tank_p2_1-0" duration="3"/>
|
|
||||||
<frame id="tank_p2_1-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
<animation id="tank_p3_1">
|
|
||||||
<frame id="tank_p3_1-0" duration="3"/>
|
|
||||||
<frame id="tank_p3_1-1" duration="3"/>
|
|
||||||
</animation>
|
|
||||||
</animations>
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 246 KiB |
Binary file not shown.
Binary file not shown.
BIN
src/client/resources/fonts/GamePlayed.eot
Normal file
BIN
src/client/resources/fonts/GamePlayed.eot
Normal file
Binary file not shown.
BIN
src/client/resources/fonts/GamePlayed.svg
Normal file
BIN
src/client/resources/fonts/GamePlayed.svg
Normal file
Binary file not shown.
BIN
src/client/resources/fonts/GamePlayed.ttf
Normal file
BIN
src/client/resources/fonts/GamePlayed.ttf
Normal file
Binary file not shown.
BIN
src/client/resources/fonts/GamePlayed.woff
Normal file
BIN
src/client/resources/fonts/GamePlayed.woff
Normal file
Binary file not shown.
@@ -19,7 +19,7 @@ class HardBotControl extends BotControl {
|
|||||||
shot();
|
shot();
|
||||||
}
|
}
|
||||||
case CELL(cell):
|
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();
|
shot();
|
||||||
}
|
}
|
||||||
case EAGLE(eagle):
|
case EAGLE(eagle):
|
||||||
@@ -32,6 +32,7 @@ class HardBotControl extends BotControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function start():Void {
|
override public function start():Void {
|
||||||
|
super.start();
|
||||||
if (handler == null) return;
|
if (handler == null) return;
|
||||||
turn(tank.rect.direction);
|
turn(tank.rect.direction);
|
||||||
if (actionTimer == null) {
|
if (actionTimer == null) {
|
||||||
@@ -49,6 +50,9 @@ class HardBotControl extends BotControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function nextAction():Void {
|
private function nextAction():Void {
|
||||||
|
if (tank == null) {
|
||||||
|
return; //ToDo: stop?
|
||||||
|
}
|
||||||
var enemy:Tank = null;
|
var enemy:Tank = null;
|
||||||
var distance:Float = Math.POSITIVE_INFINITY;
|
var distance:Float = Math.POSITIVE_INFINITY;
|
||||||
for (entity in handler.entities.iterator()) {
|
for (entity in handler.entities.iterator()) {
|
||||||
@@ -68,8 +72,9 @@ class HardBotControl extends BotControl {
|
|||||||
var d = BotHelper.getDirectionTo(tank, enemy);
|
var d = BotHelper.getDirectionTo(tank, enemy);
|
||||||
if (d != tank.rect.direction) {
|
if (d != tank.rect.direction) {
|
||||||
turn(BotHelper.getDirectionTo(tank, enemy), 1);
|
turn(BotHelper.getDirectionTo(tank, enemy), 1);
|
||||||
}
|
} else {
|
||||||
shot();
|
shot();
|
||||||
|
}
|
||||||
} else if (Math.random() > 0.8) {
|
} else if (Math.random() > 0.8) {
|
||||||
calcTurn();
|
calcTurn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ru.m.tankz.core;
|
package ru.m.tankz.core;
|
||||||
|
|
||||||
|
import haxe.Timer;
|
||||||
import haxework.color.Color;
|
import haxework.color.Color;
|
||||||
import ru.m.geom.Direction;
|
import ru.m.geom.Direction;
|
||||||
import ru.m.geom.Point;
|
import ru.m.geom.Point;
|
||||||
@@ -18,6 +19,7 @@ class Tank extends MobileEntity {
|
|||||||
public var freezing(default, null):Modificator;
|
public var freezing(default, null):Modificator;
|
||||||
|
|
||||||
private var bulletsCounter:Int = 0;
|
private var bulletsCounter:Int = 0;
|
||||||
|
private var shotDelayTimer:Timer;
|
||||||
|
|
||||||
public function new(playerId:PlayerId, config:TankConfig) {
|
public function new(playerId:PlayerId, config:TankConfig) {
|
||||||
super(new Rectangle(0, 0, config.width, config.height), config.speed, Direction.RIGHT);
|
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> {
|
public function shot():Null<Bullet> {
|
||||||
if (freezing.active) return null;
|
if (
|
||||||
if (bulletsCounter >= config.bullets) return null;
|
freezing.active ||
|
||||||
|
bulletsCounter >= config.bullets ||
|
||||||
|
shotDelayTimer != null
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
var bullet = new Bullet(this);
|
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.rect.center = rect.center.add(new Point(rect.width / 4 * rect.direction.x, rect.height / 4 * rect.direction.y));
|
||||||
bullet.move(rect.direction);
|
bullet.move(rect.direction);
|
||||||
bulletsCounter++;
|
bulletsCounter++;
|
||||||
|
shotDelayTimer = Timer.delay(function() shotDelayTimer = null, 200);
|
||||||
return bullet;
|
return bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ player:
|
|||||||
|
|
||||||
presets:
|
presets:
|
||||||
# player1
|
# player1
|
||||||
- id: player1
|
- id: 1 Player
|
||||||
teams:
|
teams:
|
||||||
- id: human
|
- id: human
|
||||||
players:
|
players:
|
||||||
@@ -51,7 +51,7 @@ presets:
|
|||||||
- {<<: *bot, index: 2}
|
- {<<: *bot, index: 2}
|
||||||
- {<<: *bot, index: 3}
|
- {<<: *bot, index: 3}
|
||||||
# player2
|
# player2
|
||||||
- id: player2
|
- id: 2 Players
|
||||||
teams:
|
teams:
|
||||||
- id: human
|
- id: human
|
||||||
players:
|
players:
|
||||||
|
|||||||
Reference in New Issue
Block a user