public static EventBullet Get(Action action, VirusBase target, float damage)
 {
     if (sIns == null)
     {
         sIns = new EventBullet();
     }
     sIns.action = action;
     sIns.target = target;
     sIns.damage = damage;
     return(sIns);
 }
        private void OnItemCollider(int index, VirusBase virus)
        {
            base.OnUnitFire(index);
            units[index].SetReady(false);
            Vector2 cDir = virus.position - units[index].position;
            Vector2 dir  = (cDir + virus.direction).normalized;

            virus.SetDirection(dir);
            Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, damage));
            ExplosionWeaponCoverItem.Create().Reset(units[index].position, table.explosionSound);
        }
Beispiel #3
0
        protected override void OnHit(VirusBase virus)
        {
            base.OnHit(virus);
            var hitPos = position + direction * 50;

            AreaHit(hitPos, effects[1] * 0.5f, (_vv) =>
            {
                Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, _vv, damage));
            });
            ExplosionWeaponMissileBullet.Create().Reset(hitPos, effects[1], explosionSound);
            ForceRecycle();
        }
 private void CheckHit()
 {
     foreach (var _v in EntityManager.GetAll <VirusBase>())
     {
         var virus = _v as VirusBase;
         if (!virus.isAlive || virus.isInvincible)
         {
             continue;
         }
         if (virus.position.y > position.y &&
             Mathf.Abs(virus.position.x - position.x) < effects[1] * 0.5f + virus.radius)
         {
             Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, damage));
         }
     }
 }
Beispiel #5
0
        private void OnEventBullet(EventBullet evt)
        {
            if (evt.target != this)
            {
                return;
            }

            if (evt.action == EventBullet.Action.HIT)
            {
                BeHit(evt.damage);
                hp = Mathf.Max(0f, hp - evt.damage);
                if (Mathf.Approximately(hp, 0))
                {
                    BeDead();
                }
            }
        }
Beispiel #6
0
        protected override void OnHit(VirusBase virus)
        {
            base.OnHit(virus);
            if (virus.isAlive && !virus.isInvincible)
            {
                Vector2 cDir = virus.position - position;
                Vector2 dir  = (cDir + virus.direction).normalized;
                virus.SetDirection(dir);
                Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, damage));
            }

            mHitCount--;
            if (mHitCount <= 0)
            {
                ForceRecycle();
                AudioManager.PlaySound(explosionSound);
            }
        }
Beispiel #7
0
        private void OnTriggerEnter2D(Collider2D _collider)
        {
            if (!isAlive)
            {
                return;
            }

            if (_collider.tag == TagUtil.Virus)
            {
                var virus = _collider.GetComponent <VirusBase>();
                if (virus != null && virus.isAlive)
                {
                    Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, mDamage));
                    PlayExplosion(virus.rectTransform.GetUIPos(), virus.radius);
                    Recycle();
                    isAlive = false;
                }
            }
        }