[client] resource images rename

This commit is contained in:
2018-02-18 21:22:46 +03:00
parent 5456a01551
commit 11aea59cf8
38 changed files with 61 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
package ru.m.tankz.engine;
import ru.m.geom.Point;
import ru.m.geom.Line;
import ru.m.geom.Point;
import ru.m.tankz.config.Config;
import ru.m.tankz.control.Control;
import ru.m.tankz.core.Bullet;
@@ -12,9 +12,15 @@ import ru.m.tankz.core.Tank;
import ru.m.tankz.map.LevelMap;
enum EntityChange {
DEATH;
HIT;
}
interface EngineListener {
public function onSpawn(entity:EntityType):Void;
public function onChange(entity:EntityType):Void;
public function onChange(entity:EntityType, ?change:EntityChange):Void;
public function onCollision(entity:EntityType, with:EntityType):Void;
public function onDestroy(entity:EntityType):Void;
}
@@ -29,7 +35,7 @@ class CollisionProcessor implements EngineListener {
public function onSpawn(entity:EntityType):Void {}
public function onChange(entity:EntityType):Void {}
public function onChange(entity:EntityType, ?change:EntityChange):Void {}
public function onCollision(entity:EntityType, with:EntityType):Void {
switch [entity, with] {
@@ -47,7 +53,7 @@ class CollisionProcessor implements EngineListener {
if (!tank.protect.active) {
if (tank.hits > 0) {
tank.hits--;
engine.change(tank);
engine.change(tank, EntityChange.HIT);
} else {
engine.destroy(tank);
}
@@ -63,7 +69,7 @@ class CollisionProcessor implements EngineListener {
engine.destroy(bullet);
if (!eagle.protect.active) {
eagle.death = true;
engine.change(eagle);
engine.change(eagle, EntityChange.DEATH);
}
case _:
}
@@ -101,9 +107,9 @@ class Engine implements ControlHandler {
for (l in listeners) l.onSpawn(type);
}
public function change(entity:Entity):Void {
public function change(entity:Entity, ?change:EntityChange):Void {
var type = EntityTypeResolver.of(entity);
for (l in listeners) l.onChange(type);
for (l in listeners) l.onChange(type, change);
}
public function destroy(entity:Entity):Void {

View File

@@ -158,13 +158,18 @@ class Game implements EngineListener {
}
}
public function onChange(entity:EntityType):Void {
switch (entity) {
case EntityType.EAGLE(eagle):
public function onChange(entity:EntityType, ?change:EntityChange):Void {
switch [entity, change] {
case [EntityType.EAGLE(eagle), EntityChange.DEATH]:
if (eagle.death) {
lose(eagle.team);
deferred.resolve(state);
}
case [EntityType.TANK(tank), EntityChange.HIT]:
if (tank.bonus) {
tank.bonus = false;
spawnBonus();
}
case _:
}
}
@@ -197,7 +202,9 @@ class Game implements EngineListener {
if (!team.isAlive) {
lose(team.id);
}
if (tank.bonus) spawnBonus();
if (tank.bonus) {
spawnBonus();
}
deferred.resolve(state);
case _:
}