[common] add deathmatch mode
This commit is contained in:
@@ -15,6 +15,11 @@ views:
|
||||
$type: ru.m.tankz.view.dota.DotaLevelFrame
|
||||
- id: dota.game
|
||||
$type: ru.m.tankz.view.dota.DotaGameFrame
|
||||
# death
|
||||
- id: death.level
|
||||
$type: ru.m.tankz.view.death.DeathLevelFrame
|
||||
- id: death.game
|
||||
$type: ru.m.tankz.view.death.DeathGameFrame
|
||||
# result
|
||||
- id: result
|
||||
$type: ru.m.tankz.view.ResultFrame
|
||||
|
||||
@@ -4,6 +4,7 @@ import haxework.view.ButtonView;
|
||||
import haxework.view.frame.FrameSwitcher;
|
||||
import haxework.view.VGroupView;
|
||||
import ru.m.tankz.view.classic.ClassicLevelFrame;
|
||||
import ru.m.tankz.view.death.DeathLevelFrame;
|
||||
import ru.m.tankz.view.dota.DotaLevelFrame;
|
||||
import ru.m.tankz.view.popup.FontPopup;
|
||||
|
||||
@@ -21,6 +22,8 @@ import ru.m.tankz.view.popup.FontPopup;
|
||||
frameSwitcher.change(ClassicLevelFrame.ID);
|
||||
case 'dota':
|
||||
frameSwitcher.change(DotaLevelFrame.ID);
|
||||
case 'death':
|
||||
frameSwitcher.change(DeathLevelFrame.ID);
|
||||
case 'network':
|
||||
//frameSwitcher.change(NetworkFrame.ID);
|
||||
case 'settings':
|
||||
|
||||
@@ -17,6 +17,11 @@ views:
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: DotA
|
||||
- id: death
|
||||
$type: haxework.view.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: DeathMatch
|
||||
# - id: font
|
||||
# $type: haxework.view.ButtonView
|
||||
# skinId: button
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package ru.m.tankz.view.common;
|
||||
|
||||
import ru.m.tankz.game.GameState;
|
||||
import flash.events.Event;
|
||||
import haxe.ds.Option;
|
||||
import haxe.Timer;
|
||||
import haxework.view.frame.FrameSwitcher;
|
||||
import haxework.view.GroupView;
|
||||
import ru.m.tankz.view.common.IGamePanel;
|
||||
import ru.m.tankz.game.Game;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.network.NetworkManager;
|
||||
import ru.m.tankz.render.Render;
|
||||
import ru.m.tankz.sound.SoundManager;
|
||||
import ru.m.tankz.view.common.IGamePanel;
|
||||
|
||||
class GameFrame extends GroupView {
|
||||
|
||||
@@ -33,7 +33,7 @@ class GameFrame extends GroupView {
|
||||
}
|
||||
|
||||
private function get_panel():IGamePanel {
|
||||
throw "Not implemented";
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
@@ -47,7 +47,9 @@ class GameFrame extends GroupView {
|
||||
game.start(state).then(onGameStateChange).endThen(onGameComplete);
|
||||
timer = new Timer(10);
|
||||
timer.run = updateEngine;
|
||||
panel.game = game;
|
||||
if (panel != null) {
|
||||
panel.game = game;
|
||||
}
|
||||
content.addEventListener(Event.ENTER_FRAME, _redraw);
|
||||
render.draw(game.engine);
|
||||
sound.play('start');
|
||||
@@ -67,7 +69,9 @@ class GameFrame extends GroupView {
|
||||
}
|
||||
|
||||
private function onGameStateChange(_):Void {
|
||||
panel.toUpdate();
|
||||
if (panel != null) {
|
||||
panel.toUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private function onGameComplete(_):Void {
|
||||
|
||||
@@ -10,6 +10,7 @@ views:
|
||||
$type: haxework.view.DataView
|
||||
factory: $this:teamViewFactory
|
||||
layout:
|
||||
$type: haxework.view.layout.HorizontalLayout
|
||||
$type: haxework.view.layout.TailLayout
|
||||
rowSize: 5
|
||||
margin: 3
|
||||
+onDataSelect: $this:onTeamSelect
|
||||
|
||||
21
src/client/haxe/ru/m/tankz/view/death/DeathGameFrame.hx
Executable file
21
src/client/haxe/ru/m/tankz/view/death/DeathGameFrame.hx
Executable file
@@ -0,0 +1,21 @@
|
||||
package ru.m.tankz.view.death;
|
||||
|
||||
import ru.m.tankz.render.Render;
|
||||
import ru.m.tankz.view.common.GameFrame;
|
||||
import ru.m.tankz.view.common.IGamePanel;
|
||||
|
||||
@:template class DeathGameFrame extends GameFrame {
|
||||
|
||||
public static inline var ID = "death.game";
|
||||
|
||||
@:view("render") private var renderView(default, null):Render;
|
||||
//@:view("panel") private var panelView(default, null):IGamePanel;
|
||||
|
||||
override private function get_render():Render {
|
||||
return renderView;
|
||||
}
|
||||
|
||||
/*override private function get_panel():IGamePanel {
|
||||
return panelView;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
skinId: container
|
||||
views:
|
||||
- $type: haxework.view.VGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
- id: render
|
||||
$type: ru.m.tankz.render.Render
|
||||
37
src/client/haxe/ru/m/tankz/view/death/DeathLevelFrame.hx
Normal file
37
src/client/haxe/ru/m/tankz/view/death/DeathLevelFrame.hx
Normal file
@@ -0,0 +1,37 @@
|
||||
package ru.m.tankz.view.death;
|
||||
|
||||
import haxework.view.ButtonView;
|
||||
import haxework.view.DataView;
|
||||
import haxework.view.frame.FrameSwitcher;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.preset.DeathGame;
|
||||
import ru.m.tankz.view.common.LevelFrame;
|
||||
import ru.m.tankz.view.common.PlayerView;
|
||||
|
||||
@:template class DeathLevelFrame extends LevelFrame {
|
||||
public static inline var ID = "death.level";
|
||||
|
||||
@:view var levels(default, null):DataView<Int, ButtonView>;
|
||||
@:view var players(default, null):DataView<Array<PlayerState>, PlayerView>;
|
||||
|
||||
@:provide var frames:FrameSwitcher;
|
||||
|
||||
private function onShow():Void {
|
||||
gameType = DeathGame.TYPE;
|
||||
levels.data = [for (i in 0...config.game.levels) i];
|
||||
players.data = [for (i in 0...2) state.players];
|
||||
}
|
||||
|
||||
private function playerViewFactory(index:Int, data:Array<PlayerState>):PlayerView {
|
||||
var view = new PlayerView();
|
||||
view.item_index = index;
|
||||
view.data = data;
|
||||
return view;
|
||||
}
|
||||
|
||||
override private function set_level(value:Int):Int {
|
||||
var result = super.set_level(value);
|
||||
frames.change(DeathGameFrame.ID);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
24
src/client/haxe/ru/m/tankz/view/death/DeathLevelFrame.yaml
Normal file
24
src/client/haxe/ru/m/tankz/view/death/DeathLevelFrame.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
skinId: container
|
||||
layout:
|
||||
$type: haxework.view.layout.VerticalLayout
|
||||
views:
|
||||
- $type: haxework.view.LabelView
|
||||
skinId: text.header
|
||||
text: DeathMatch
|
||||
- id: players
|
||||
$type: haxework.view.DataView
|
||||
layout:
|
||||
$type: haxework.view.layout.VerticalLayout
|
||||
hAlign: right
|
||||
factory: $this:playerViewFactory
|
||||
geometry.padding: 10
|
||||
- id: levels
|
||||
$type: haxework.view.DataView
|
||||
layout:
|
||||
$type: haxework.view.layout.TailLayout
|
||||
rowSize: 5
|
||||
margin: 5
|
||||
factory: $this:levelViewFactory
|
||||
+onDataSelect: $code:function(value) level = value
|
||||
geometry.padding: 10
|
||||
7
src/common/haxe/ru/m/tankz/preset/DeathGame.hx
Normal file
7
src/common/haxe/ru/m/tankz/preset/DeathGame.hx
Normal file
@@ -0,0 +1,7 @@
|
||||
package ru.m.tankz.preset;
|
||||
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
class DeathGame {
|
||||
public static var TYPE(default, never):GameType = 'death';
|
||||
}
|
||||
89
src/common/resources/death/config.yaml
Normal file
89
src/common/resources/death/config.yaml
Normal file
@@ -0,0 +1,89 @@
|
||||
game:
|
||||
levels: 1
|
||||
friendlyFire: true
|
||||
complete: []
|
||||
|
||||
map:
|
||||
cellWidth: 22
|
||||
cellHeight: 22
|
||||
gridWidth: 20
|
||||
gridHeight: 20
|
||||
|
||||
bricks:
|
||||
- {type: border, index: -1, layer: 2, armor: -1}
|
||||
- {type: none, index: 0, layer: 0, armor: 0}
|
||||
- {type: ace, index: 1, layer: 0, armor: 0}
|
||||
- {type: bush, index: 2, layer: 3, armor: 0}
|
||||
- {type: water, index: 3, layer: 1, armor: 0}
|
||||
- {type: armor, index: 4, layer: 2, armor: 2}
|
||||
- {type: brick, index: 5, layer: 2, armor: 1}
|
||||
|
||||
player:
|
||||
default: &player
|
||||
protect: 3
|
||||
tanks:
|
||||
- {type: default, rate: 1}
|
||||
|
||||
team:
|
||||
base: &team
|
||||
life: 10
|
||||
players:
|
||||
- {<<: *player, index: 0}
|
||||
|
||||
presets:
|
||||
- id: default
|
||||
teams:
|
||||
- id: alpha
|
||||
color: 0xFF4422
|
||||
<<: *team
|
||||
- id: beta
|
||||
color: 0xFFD000
|
||||
<<: *team
|
||||
- id: gamma
|
||||
color: 0x3EFE00
|
||||
<<: *team
|
||||
- id: delta
|
||||
color: 0x00FFF8
|
||||
<<: *team
|
||||
- id: epsilon
|
||||
color: 0x00B37F
|
||||
<<: *team
|
||||
- id: zeta
|
||||
color: 0xFC00FF
|
||||
<<: *team
|
||||
- id: eta
|
||||
color: 0x8F00FD
|
||||
<<: *team
|
||||
- id: theta
|
||||
color: 0xB66F00
|
||||
<<: *team
|
||||
|
||||
points:
|
||||
- {team: alpha, type: tank, index: 0, direction: right, x: 0, y: 0}
|
||||
- {team: beta, type: tank, index: 0, direction: right, x: 2, y: 0}
|
||||
- {team: gamma, type: tank, index: 0, direction: right, x: 4, y: 0}
|
||||
- {team: delta, type: tank, index: 0, direction: right, x: 6, y: 0}
|
||||
- {team: epsilon, type: tank, index: 0, direction: right, x: 0, y: 2}
|
||||
- {team: zeta, type: tank, index: 0, direction: right, x: 2, y: 2}
|
||||
- {team: eta, type: tank, index: 0, direction: right, x: 4, y: 2}
|
||||
- {team: theta, type: tank, index: 0, direction: right, x: 6, y: 2}
|
||||
|
||||
bullet: &bullet
|
||||
width: 12
|
||||
height: 12
|
||||
speed: 0
|
||||
piercing: 1
|
||||
|
||||
tanks:
|
||||
- type: default
|
||||
width: 38
|
||||
height: 36
|
||||
speed: 2.3
|
||||
bullet:
|
||||
<<: *bullet
|
||||
speed: 12.0
|
||||
bullets: 2
|
||||
score: 100
|
||||
skin: pc
|
||||
|
||||
bonuses: []
|
||||
2
src/common/resources/death/levels/level000.txt
Normal file
2
src/common/resources/death/levels/level000.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
points: [{y: 0, team: alpha, x: 0, direction: right, type: tank, index: 0}, {y: 0, team: beta, x: 6, direction: right, type: tank, index: 0}, {y: 0, team: gamma, x: 12, direction: right, type: tank, index: 0}, {y: 0, team: delta, x: 18, direction: right, type: tank, index: 0}, {y: 18, team: epsilon, x: 0, direction: right, type: tank, index: 0}, {y: 18, team: zeta, x: 6, direction: right, type: tank, index: 0}, {y: 18, team: eta, x: 12, direction: right, type: tank, index: 0}, {y: 18, team: theta, x: 18, direction: right, type: tank, index: 0}]
|
||||
data: "0004400004400004400000044000044000044000555555555555555555550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000555555555555555555550004400004400004400000044000044000044000"
|
||||
@@ -29,7 +29,8 @@ import ru.m.tankz.util.LevelUtil;
|
||||
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
||||
@:view var brickList:DataView<BrickConfig, BrickView>;
|
||||
|
||||
private var config:Config;
|
||||
@:provide var configBundle:IConfigBundle;
|
||||
@:provide var config:Config;
|
||||
|
||||
public function init():Void {
|
||||
var resetSelected = function() {
|
||||
@@ -59,8 +60,7 @@ import ru.m.tankz.util.LevelUtil;
|
||||
}
|
||||
|
||||
private function setGameType(type:GameType):Void {
|
||||
config = Provider.get(IConfigBundle).get(type);
|
||||
Provider.set(Config, config);
|
||||
config = configBundle.get(type);
|
||||
|
||||
mapView.config = config;
|
||||
mapView.data = LevelUtil.empty(config);
|
||||
|
||||
@@ -7,16 +7,18 @@ layout.hAlign: center
|
||||
views:
|
||||
- $type: haxework.view.HGroupView
|
||||
views:
|
||||
- id: gameClassicButton
|
||||
$type: haxework.view.ButtonView
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: Classic
|
||||
+onPress: $this:onPress
|
||||
- id: gameDotaButton
|
||||
$type: haxework.view.ButtonView
|
||||
+onPress: $code:setGameType('classic')
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: DotA
|
||||
+onPress: $this:onPress
|
||||
+onPress: $code:setGameType('dota')
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: DeathMatch
|
||||
+onPress: $code:setGameType('death')
|
||||
- id: fileNameLabel
|
||||
$type: haxework.view.LabelView
|
||||
# map
|
||||
|
||||
Reference in New Issue
Block a user