[common] add boat bonus
[client] add active style to gamepad buttons
This commit is contained in:
@@ -19,6 +19,7 @@ typedef TankInfo = {
|
||||
var skin:String;
|
||||
var hits:Int;
|
||||
var bonus:Bool;
|
||||
var boat:Bool;
|
||||
var color:Color;
|
||||
@:optional var name:String;
|
||||
}
|
||||
|
||||
19
src/common/haxe/ru/m/tankz/bonus/BoatBonus.hx
Normal file
19
src/common/haxe/ru/m/tankz/bonus/BoatBonus.hx
Normal file
@@ -0,0 +1,19 @@
|
||||
package ru.m.tankz.bonus;
|
||||
|
||||
import ru.m.tankz.core.Tank;
|
||||
import ru.m.tankz.engine.IEngine;
|
||||
import ru.m.tankz.game.IGame;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
using ru.m.tankz.game.GameUtil;
|
||||
|
||||
class BoatBonus extends BaseBonus {
|
||||
|
||||
public static inline var CLASS = "boat";
|
||||
|
||||
override public function apply(playerId:PlayerId, game:IGame, engine:IEngine):Void {
|
||||
var tank:Tank = engine.getEntity(game.getPlayer(playerId).tankId);
|
||||
tank.boat = true;
|
||||
game.emitTankChange(tank);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class BonusFactory {
|
||||
ProtectTankBonus.CLASS => ProtectTankBonus,
|
||||
UpgradeTankBonus.CLASS => UpgradeTankBonus,
|
||||
SuicideTankBonus.CLASS => SuicideTankBonus,
|
||||
BoatBonus.CLASS => BoatBonus,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ class MobileEntity extends Entity {
|
||||
public var mx(default, default):Float;
|
||||
public var my(default, default):Float;
|
||||
|
||||
public var layer(default, null):Int;
|
||||
public var layer(get, null):Int;
|
||||
private function get_layer():Int return layer;
|
||||
|
||||
public var speed(default, null):Float;
|
||||
|
||||
public function new(id:Int, rect:Rectangle, speed:Float, direction:Direction) {
|
||||
|
||||
@@ -16,11 +16,14 @@ class Tank extends MobileEntity {
|
||||
public var bonus(default, default):Bool;
|
||||
public var protect(default, default):Bool;
|
||||
public var freezing(default, default):Bool;
|
||||
public var boat(default, default):Bool;
|
||||
|
||||
public var weapons(default, null):Array<Weapon>;
|
||||
public var weapon(get, null):Weapon;
|
||||
public var info(get, null):TankInfo;
|
||||
|
||||
override function get_layer():Int return layer + (boat ? 1 : 0);
|
||||
|
||||
public function new(id:Int, rect:Rectangle, playerId:PlayerId, config:TankConfig) {
|
||||
super(id, rect, config.speed, Direction.RIGHT);
|
||||
this.protect = false;
|
||||
@@ -51,6 +54,7 @@ class Tank extends MobileEntity {
|
||||
skin: config.skin,
|
||||
hits: hits,
|
||||
bonus: bonus,
|
||||
boat: boat,
|
||||
color: color,
|
||||
name: name,
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ enum StopEvent {
|
||||
}
|
||||
|
||||
enum ChangeEvent {
|
||||
TANK(id:Int, type:TankType, hits:Int, bonus:Bool);
|
||||
TANK(id:Int, type:TankType, hits:Int, bonus:Bool, boat:Bool);
|
||||
TANK_PROTECT(id:Int, state:Bool);
|
||||
TANK_FREEZE(id:Int, state:Bool);
|
||||
EAGLE_PROTECT(id:Int, state:Bool);
|
||||
|
||||
@@ -74,6 +74,7 @@ class GameRunner extends Game implements EngineListener {
|
||||
skin:tank.skin,
|
||||
hits:tank.hits,
|
||||
bonus:bonus,
|
||||
boat:false,
|
||||
color:player.state.color,
|
||||
name:player.state.name,
|
||||
}
|
||||
@@ -189,7 +190,10 @@ class GameRunner extends Game implements EngineListener {
|
||||
// Nothing
|
||||
} else {
|
||||
if (!tank.protect) {
|
||||
if (tank.hits > 0) {
|
||||
if (tank.boat) {
|
||||
tank.boat = false;
|
||||
emitTankChange(tank);
|
||||
} else if (tank.hits > 0) {
|
||||
tank.hits--;
|
||||
if (tank.bonus) {
|
||||
tank.bonus = false;
|
||||
@@ -310,7 +314,7 @@ class GameRunner extends Game implements EngineListener {
|
||||
bullet.weapon.use();
|
||||
case CHANGE(BRICK(id, type)):
|
||||
engine.map.bricksById[id].config = config.getBrick(type);
|
||||
case CHANGE(TANK(id, type, hits, bonus)):
|
||||
case CHANGE(TANK(id, type, hits, bonus, boat)):
|
||||
var tank:Tank = engine.getEntity(id);
|
||||
getPlayer(tank.playerId).state.tank = tank.info;
|
||||
case DESTROY(EAGLE(id, shot)):
|
||||
|
||||
@@ -27,7 +27,7 @@ class GameUtil {
|
||||
}
|
||||
|
||||
public static inline function emitTankChange(game:IGame, tank:Tank):Void {
|
||||
game.gameEventSignal.emit(CHANGE(TANK(tank.id, tank.config.type, tank.hits, tank.bonus)));
|
||||
game.gameEventSignal.emit(CHANGE(TANK(tank.id, tank.config.type, tank.hits, tank.bonus, tank.boat)));
|
||||
}
|
||||
|
||||
public static function protectTank(game:IGame, tank:Tank, duration:Float):Void {
|
||||
|
||||
@@ -159,6 +159,7 @@ bonuses:
|
||||
- {score: 500, factory: armor.eagle, type: shovel, duration: 15}
|
||||
- {score: 500, factory: upgrade.tank, type: star, value: 1}
|
||||
- {score: 500, factory: upgrade.tank, type: gun, value: 5}
|
||||
- {score: 500, factory: boat, type: boat}
|
||||
|
||||
presets:
|
||||
- id: 0
|
||||
|
||||
@@ -115,3 +115,4 @@ bonuses:
|
||||
- {score: 100, factory: protect.tank, type: helmet, duration: 15}
|
||||
- {score: 100, factory: life, type: life}
|
||||
- {score: 100, factory: protect.eagle, type: shovel, duration: 10}
|
||||
- {score: 500, factory: boat, type: boat}
|
||||
|
||||
Reference in New Issue
Block a user