void HandleDestroyBullet(DataBullet bullet, int index) { if (bullet.killed) { return; } bullet.killed = true; var entity = group_bullets.entities[index]; ProcessingGoPool.Default.Despawn(Pool.Projectiles, bullet.tr.gameObject); ProcessingEntities.Remove <DataBullet>(entity); ProcessingEntities.KillEntity(entity); }
public void Shoot(int speed, Vector3 position, Quaternion rotation) { for (var i = 0; i < 1; i++) { var obj = this.Populate(Pool.Projectiles, prefab_bullet, position, rotation); var entity = ProcessingEntities.AddEntity(); var dataBullet = new DataBullet(); dataBullet.speed = speed; dataBullet.tr = obj; Storage <DataBullet> .Instance.AddVirtual(dataBullet, entity); } }
void HandleCheck(DataBullet bullet, int index) { var hits = Physics2D.CircleCastNonAlloc(bullet.tr.position, 0.4f, Vector2.zero, ExtGame.hits); for (var i = 0; i < hits; i++) { var hit = ExtGame.hits[i]; var actor = hit.GetActor(); if (actor == null || !actor.HasTag(Tag.GroupEnemy)) { continue; } if (actor.HasTag(Tag.StateKiiled)) { continue; } actor.AddTag(Tag.StateKiiled); HandleDestroyBullet(bullet, index); return; } }