Enemy projectiles

This commit is contained in:
Martin 2022-12-30 15:19:32 +01:00
parent 2c2c9e923f
commit 354be800ec
5 changed files with 48 additions and 70 deletions

View File

@ -257,37 +257,6 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "5dR8969SVAfLXx5AY1X9B5"
},
{
"__type__": "7f8b6NKHsNNW5nLY3fwejhw",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"collider": {
"__id__": 10
},
"sprite": {
"__id__": 5
},
"defaultMaterial": {
"__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
"__expectedType__": "cc.Material"
},
"whiteMaterial": {
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
"__expectedType__": "cc.Material"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b5ONKVkchBpaoqReE981lo"
},
{
"__type__": "cc.Animation",
"_name": "",
@ -297,7 +266,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 15
"__id__": 13
},
"playOnLoad": true,
"_clips": [
@ -316,6 +285,26 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "74x/uTmM5C8J/ZyOW71lz5"
},
{
"__type__": "6a24eYAhmtMDZo5Wb8iLC5Q",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"collider": {
"__id__": 10
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1dAsEzyaRFLKP5Bpu453Ag"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -257,37 +257,6 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "5dR8969SVAfLXx5AY1X9B5"
},
{
"__type__": "7f8b6NKHsNNW5nLY3fwejhw",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 13
},
"collider": {
"__id__": 10
},
"sprite": {
"__id__": 5
},
"defaultMaterial": {
"__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
"__expectedType__": "cc.Material"
},
"whiteMaterial": {
"__uuid__": "9cb17675-370b-48ed-bfa2-bb613a88af44",
"__expectedType__": "cc.Material"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b5ONKVkchBpaoqReE981lo"
},
{
"__type__": "cc.Animation",
"_name": "",
@ -297,7 +266,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 15
"__id__": 13
},
"playOnLoad": true,
"_clips": [
@ -316,6 +285,26 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "74x/uTmM5C8J/ZyOW71lz5"
},
{
"__type__": "6a24eYAhmtMDZo5Wb8iLC5Q",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 15
},
"collider": {
"__id__": 10
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d5iBqvxQdEL7D53HbXiPXQ"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@ -784,7 +784,7 @@
"_enabled": true,
"__prefab": null,
"projectilePrefab": {
"__uuid__": "d20eb25c-f8b8-436e-b59c-2c3dbd87b25a",
"__uuid__": "70a69a09-9531-49c5-8671-1732767f94dd",
"__expectedType__": "cc.Prefab"
},
"_id": "85yfYEMEFN8YoT2mjsrgxI"

View File

@ -15,7 +15,7 @@ export class Projectile extends Component {
private piercesLeft = 0;
private damage = 0;
public init(damage: number, pierces: number, angle: number): void {
public setup(damage: number, pierces: number, angle: number): void {
this.piercesLeft = pierces;
this.damage = damage;

View File

@ -13,7 +13,7 @@ const { ccclass, property } = _decorator;
export class ProjectileLauncher extends Component implements IProjectileLauncherSignaler {
@property(Prefab) private projectilePrefab: Prefab;
private projectileCollisionEvent = new Signal<ProjectileCollision>();
private projectileLauncehdEvent = new Signal();
private projectileLaunchedEvent = new Signal();
private projectileDamage: number;
private projectilePierces: number;
@ -32,7 +32,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
}
public get ProjectileLaunchedEvent(): ISignal {
return this.projectileLauncehdEvent;
return this.projectileLaunchedEvent;
}
public init(projectileLifetime: number, projectileSpeed: number, projectileDamage: number, projectilePierces: number): void {
@ -61,7 +61,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
private fireProjectile(startPosition: Vec3, direction: Vec2): void {
direction = direction.normalize();
const projectile: Projectile = this.projectilePool.borrow();
projectile.init(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y));
projectile.setup(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y));
projectile.node.setWorldPosition(startPosition);
projectile.node.active = true;
projectile.ContactBeginEvent.on(this.onProjectileCollision, this);
@ -71,7 +71,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
this.directions.push(direction);
this.expireTimes.push(this.currentTime + this.projectileLifetime);
this.projectileLauncehdEvent.trigger({});
this.projectileLaunchedEvent.trigger();
}
private tryRemoveExpiredProjectiles(): void {