mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
White flashing
This commit is contained in:
parent
6306228569
commit
c2bf40b471
@ -55,8 +55,8 @@
|
||||
"upgrades": {
|
||||
"maxWeaponLengthUpgrades": 5,
|
||||
"maxWeaponDamageUpgrades": 10,
|
||||
"maxHorizontalProjectileUpgrades": 0,
|
||||
"maxDiagonalProjectileUpgrades": 0,
|
||||
"maxHorizontalProjectileUpgrades": 5,
|
||||
"maxDiagonalProjectileUpgrades": 5,
|
||||
"maxHaloProjectileUpgrades": 5,
|
||||
"maxRegenerationUpgrades": 5
|
||||
},
|
||||
@ -144,7 +144,7 @@
|
||||
"damage": 1,
|
||||
"speed": 60,
|
||||
"lifetime": -1,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0
|
||||
},
|
||||
{
|
||||
@ -155,7 +155,7 @@
|
||||
"damage": 2,
|
||||
"speed": 65,
|
||||
"lifetime": -1,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.1
|
||||
},
|
||||
{
|
||||
@ -166,7 +166,7 @@
|
||||
"damage": 2,
|
||||
"speed": 75,
|
||||
"lifetime": -1,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.1
|
||||
},
|
||||
{
|
||||
@ -177,7 +177,7 @@
|
||||
"damage": 1,
|
||||
"speed": 25,
|
||||
"lifetime": 29,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1
|
||||
},
|
||||
{
|
||||
@ -188,7 +188,7 @@
|
||||
"damage": 2,
|
||||
"speed": 35,
|
||||
"lifetime": 27,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 2
|
||||
},
|
||||
{
|
||||
@ -199,7 +199,7 @@
|
||||
"damage": 2,
|
||||
"speed": 390,
|
||||
"lifetime": 20,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 0.2
|
||||
},
|
||||
{
|
||||
@ -210,7 +210,7 @@
|
||||
"damage": 3,
|
||||
"speed": 70,
|
||||
"lifetime": 30,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1
|
||||
},
|
||||
{
|
||||
@ -221,7 +221,7 @@
|
||||
"damage": 3,
|
||||
"speed": 320,
|
||||
"lifetime": 30,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1
|
||||
},
|
||||
{
|
||||
@ -232,7 +232,7 @@
|
||||
"damage": 2,
|
||||
"speed": 65,
|
||||
"lifetime": -1,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 3
|
||||
},
|
||||
{
|
||||
@ -254,7 +254,7 @@
|
||||
"damage": 1,
|
||||
"speed": 120,
|
||||
"lifetime": -1,
|
||||
"xpReward": 0,
|
||||
"xpReward": 1,
|
||||
"goldReward": 1
|
||||
}
|
||||
],
|
||||
|
@ -182,6 +182,13 @@
|
||||
"collider": {
|
||||
"__id__": 6
|
||||
},
|
||||
"sprite": {
|
||||
"__id__": 4
|
||||
},
|
||||
"whiteMaterial": {
|
||||
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
|
||||
"__expectedType__": "cc.Material"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@ -182,6 +182,13 @@
|
||||
"collider": {
|
||||
"__id__": 6
|
||||
},
|
||||
"sprite": {
|
||||
"__id__": 4
|
||||
},
|
||||
"whiteMaterial": {
|
||||
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
|
||||
"__expectedType__": "cc.Material"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@ -182,6 +182,13 @@
|
||||
"collider": {
|
||||
"__id__": 6
|
||||
},
|
||||
"sprite": {
|
||||
"__id__": 4
|
||||
},
|
||||
"whiteMaterial": {
|
||||
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
|
||||
"__expectedType__": "cc.Material"
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@ -196,7 +196,7 @@
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"startTime": 0,
|
||||
"startXP": 10,
|
||||
"startXP": 0,
|
||||
"maxHpLevel": 0,
|
||||
"bonusDamageLevel": 0,
|
||||
"projectilePiercingLevel": 0,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { BoxCollider2D, Component, randomRange, Vec3, _decorator } from "cc";
|
||||
import { time } from "console";
|
||||
import { BoxCollider2D, Component, Material, randomRange, Sprite, Vec3, _decorator } from "cc";
|
||||
import { ISignal } from "../../../Services/EventSystem/ISignal";
|
||||
import { Signal } from "../../../Services/EventSystem/Signal";
|
||||
import { delay } from "../../../Services/Utils/AsyncUtils";
|
||||
import { EnemySettings } from "../../Data/GameSettings";
|
||||
import { UnitHealth } from "../UnitHealth";
|
||||
import { EnemyMovementType } from "./EnemyMovementType";
|
||||
@ -10,11 +10,15 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("Enemy")
|
||||
export class Enemy extends Component {
|
||||
@property(BoxCollider2D) public collider: BoxCollider2D;
|
||||
@property(BoxCollider2D) private collider: BoxCollider2D;
|
||||
@property(Sprite) private sprite: Sprite;
|
||||
@property(Material) private whiteMaterial: Material;
|
||||
|
||||
private deathEvent: Signal<Enemy> = new Signal<Enemy>();
|
||||
private lifetimeEndedEvent: Signal<Enemy> = new Signal<Enemy>();
|
||||
|
||||
private defaultMaterial: Material;
|
||||
|
||||
private movementType: EnemyMovementType;
|
||||
private health: UnitHealth;
|
||||
private damage: number;
|
||||
@ -26,6 +30,8 @@ export class Enemy extends Component {
|
||||
private goldReward: number;
|
||||
|
||||
public setup(position: Vec3, settings: EnemySettings): void {
|
||||
this.defaultMaterial = this.sprite.material;
|
||||
|
||||
this.movementType = <EnemyMovementType>settings.moveType;
|
||||
this.health = new UnitHealth(settings.health);
|
||||
this.damage = settings.damage;
|
||||
@ -38,6 +44,8 @@ export class Enemy extends Component {
|
||||
|
||||
this.node.setWorldPosition(position);
|
||||
this.node.active = true;
|
||||
|
||||
this.health.HealthPointsChangeEvent.on(this.animateHurt, this);
|
||||
}
|
||||
|
||||
public get MovementType(): EnemyMovementType {
|
||||
@ -60,6 +68,14 @@ export class Enemy extends Component {
|
||||
return this.deathEvent;
|
||||
}
|
||||
|
||||
public get XPReward(): number {
|
||||
return this.xpReward;
|
||||
}
|
||||
|
||||
public get GoldReward(): number {
|
||||
return this.goldReward;
|
||||
}
|
||||
|
||||
public get LifetimeEndedEvent(): ISignal<Enemy> {
|
||||
return this.lifetimeEndedEvent;
|
||||
}
|
||||
@ -85,4 +101,10 @@ export class Enemy extends Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async animateHurt(): Promise<void> {
|
||||
this.sprite.material = this.whiteMaterial;
|
||||
await delay(100);
|
||||
this.sprite.material = this.defaultMaterial;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Component, Node, _decorator } from "cc";
|
||||
import { Component, Node, randomRange, Vec3, _decorator } from "cc";
|
||||
|
||||
import { EnemyManagerSettings } from "../../Data/GameSettings";
|
||||
import { XPSpawner } from "../../XP/XPSpawner";
|
||||
import { Enemy } from "./Enemy";
|
||||
@ -64,7 +65,13 @@ export class EnemyManager extends Component {
|
||||
private onEnemyDied(enemy: Enemy): void {
|
||||
enemy.DeathEvent.off(this.onEnemyDied);
|
||||
enemy.LifetimeEndedEvent.off(this.onEnemyLifetimeEnded);
|
||||
this.xpSpawner.spawnXp(enemy.node.worldPosition, 1);
|
||||
|
||||
for (let index = 0; index < enemy.XPReward; index++) {
|
||||
const position: Vec3 = enemy.node.worldPosition;
|
||||
position.x += randomRange(-10, 10);
|
||||
position.y += randomRange(-10, 10);
|
||||
this.xpSpawner.spawnXp(position, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private onEnemyLifetimeEnded(enemy: Enemy): void {
|
||||
|
Loading…
Reference in New Issue
Block a user