[common] add ArmorEagleBonus
This commit is contained in:
26
src/client/haxe/ru/m/tankz/render/RenderUtil.hx
Normal file
26
src/client/haxe/ru/m/tankz/render/RenderUtil.hx
Normal file
@@ -0,0 +1,26 @@
|
||||
package ru.m.tankz.render;
|
||||
|
||||
import flash.display.BitmapData;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
class RenderUtil {
|
||||
|
||||
public static function eagleImage(death:Bool = false):BitmapData {
|
||||
var suffix = death ? '-death' : '';
|
||||
return Assets.getBitmapData('resources/image/eagle/eagle${suffix}.png');
|
||||
}
|
||||
|
||||
public static function tankImage(skin:String, frame:Int = 0):BitmapData {
|
||||
return Assets.getBitmapData('resources/image/tank/${skin}-${frame}.png');
|
||||
}
|
||||
|
||||
public static function bonusImage(type:BonusType):BitmapData {
|
||||
return Assets.getBitmapData('resources/image/bonus/${type}.png');
|
||||
}
|
||||
|
||||
public static function bulletImage(piercing:Int = 0):BitmapData {
|
||||
var type = piercing > 0 ? 'piercing' : 'normal';
|
||||
return Assets.getBitmapData('resources/image/bullet/${type}.png');
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,11 @@ import flash.display.Bitmap;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.PixelSnapping;
|
||||
import openfl.Assets;
|
||||
import ru.m.geom.Rectangle;
|
||||
|
||||
class BitmapRenderItem extends RenderItem {
|
||||
public var image(default, set):String;
|
||||
public var image(default, set):BitmapData;
|
||||
|
||||
private var bitmapData:BitmapData;
|
||||
private var bitmap:Bitmap;
|
||||
|
||||
public function new(rect:Rectangle) {
|
||||
@@ -22,11 +20,10 @@ class BitmapRenderItem extends RenderItem {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private function set_image(value:String):String {
|
||||
private function set_image(value:BitmapData):BitmapData {
|
||||
if (image != value) {
|
||||
image = value;
|
||||
bitmapData = Assets.getBitmapData(image);
|
||||
bitmap.bitmapData = bitmapData;
|
||||
bitmap.bitmapData = image;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class BonusRenderItem extends BitmapRenderItem {
|
||||
private function set_type(value:BonusType):BonusType {
|
||||
if (type != value) {
|
||||
type = value;
|
||||
image = 'resources/image/bonus/${type}.png';
|
||||
image = RenderUtil.bonusImage(type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,19 @@ class BrickRenderItem extends RenderItem {
|
||||
private var shape:Shape;
|
||||
private var cells:Array<Point>;
|
||||
|
||||
public function new(rect:Rectangle, type:BrickType) {
|
||||
super(rect);
|
||||
this.shape = new Shape();
|
||||
cells = [
|
||||
private static function buildCells():Array<Point> {
|
||||
return [
|
||||
new Point(0, 0),
|
||||
new Point(0, 1),
|
||||
new Point(1, 0),
|
||||
new Point(1, 1),
|
||||
];
|
||||
}
|
||||
|
||||
public function new(rect:Rectangle, type:BrickType) {
|
||||
super(rect);
|
||||
this.shape = new Shape();
|
||||
cells = buildCells();
|
||||
this.type = type;
|
||||
move(rect.position);
|
||||
}
|
||||
@@ -51,6 +55,7 @@ class BrickRenderItem extends RenderItem {
|
||||
private function set_type(value:BrickType):BrickType {
|
||||
if (type != value) {
|
||||
type = value;
|
||||
cells = buildCells();
|
||||
image = Assets.getBitmapData('resources/image/map/${type}.png');
|
||||
redraw();
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ class BulletRenderItem extends BitmapRenderItem {
|
||||
private function set_piercing(value:Int):Int {
|
||||
if (piercing != value) {
|
||||
piercing = value;
|
||||
var type = piercing > 0 ? 'piercing' : 'normal';
|
||||
image = 'resources/image/bullet/${type}.png';
|
||||
image = RenderUtil.bulletImage(piercing);
|
||||
}
|
||||
return piercing;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ class EagleRenderItem extends BitmapRenderItem {
|
||||
if (protect != value) {
|
||||
protect = value;
|
||||
if (protect) {
|
||||
protectView.x = (bitmapData.width - protectView.frames[0].image.width) / 2;
|
||||
protectView.y = (bitmapData.height - protectView.frames[0].image.height) / 2;
|
||||
protectView.x = (image.width - protectView.frames[0].image.width) / 2;
|
||||
protectView.y = (image.height - protectView.frames[0].image.height) / 2;
|
||||
}
|
||||
protectView.visible = protect;
|
||||
protectView.playing = protect;
|
||||
@@ -47,10 +47,9 @@ class EagleRenderItem extends BitmapRenderItem {
|
||||
private function set_death(value:Bool):Bool {
|
||||
if (death != value) {
|
||||
death = value;
|
||||
var suffix = death ? '-death' : '';
|
||||
image = 'resources/image/eagle/eagle${suffix}.png';
|
||||
image = RenderUtil.eagleImage(death);
|
||||
if (!color.zero) {
|
||||
bitmap.bitmapData = bitmapData = BitmapUtil.colorize(bitmapData, color);
|
||||
bitmap.bitmapData = image = BitmapUtil.colorize(image, color);
|
||||
}
|
||||
}
|
||||
return death;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.m.tankz.render.item;
|
||||
|
||||
import haxework.view.theme.ITheme;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
@@ -9,8 +8,8 @@ import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFormat;
|
||||
import haxework.color.Color;
|
||||
import haxework.text.BitmapTextField;
|
||||
import haxework.view.theme.ITheme;
|
||||
import haxework.view.utils.BitmapUtil;
|
||||
import openfl.Assets;
|
||||
import ru.m.animate.Animate;
|
||||
import ru.m.geom.Rectangle;
|
||||
|
||||
@@ -62,8 +61,8 @@ class TankRenderItem extends BitmapRenderItem {
|
||||
}
|
||||
|
||||
private function redraw():Void {
|
||||
var image1 = Assets.getBitmapData('resources/image/tank/${skin}-0.png');
|
||||
var image2 = Assets.getBitmapData('resources/image/tank/${skin}-1.png');
|
||||
var image1 = RenderUtil.tankImage(skin, 0);
|
||||
var image2 = RenderUtil.tankImage(skin, 1);
|
||||
var color1:Color = switch hits {
|
||||
case 1: 0x869C43;
|
||||
case 2: 0xDEAF80;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.m.tankz.view.common;
|
||||
|
||||
import haxework.view.ImageView;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.game.GameEvent;
|
||||
import ru.m.tankz.render.RenderUtil;
|
||||
|
||||
class TankView extends ImageView {
|
||||
|
||||
@@ -16,7 +16,7 @@ class TankView extends ImageView {
|
||||
private function set_tank(value:TankInfo):TankInfo {
|
||||
if (value != null) {
|
||||
color = value.color;
|
||||
image = Assets.getBitmapData('resources/image/tank/${value.skin}-0.png');
|
||||
image = RenderUtil.tankImage(value.skin);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package ru.m.tankz.view.result;
|
||||
|
||||
import openfl.utils.Assets;
|
||||
import haxework.view.form.LabelView;
|
||||
import haxework.view.group.HGroupView;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.render.RenderUtil;
|
||||
import ru.m.tankz.view.common.TankView;
|
||||
|
||||
@:template class FragView extends HGroupView {
|
||||
@@ -16,15 +16,18 @@ import ru.m.tankz.view.common.TankView;
|
||||
|
||||
private function set_data(value:Frag):Frag {
|
||||
data = value;
|
||||
titleView.text = data.playerId.format();
|
||||
scoreView.text = data.score.format();
|
||||
switch data.target {
|
||||
case TANK(tank):
|
||||
tankView.tank = tank;
|
||||
case EAGLE(color):
|
||||
tankView.image = Assets.getBitmapData('resources/image/eagle/eagle.png');
|
||||
tankView.image = RenderUtil.eagleImage();
|
||||
tankView.color = color;
|
||||
case BONUS(type):
|
||||
tankView.image = RenderUtil.bonusImage(type);
|
||||
titleView.text = type;
|
||||
}
|
||||
titleView.text = data.playerId.format();
|
||||
scoreView.text = data.score.format();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user