protected override void ProcessEntities(Dictionary <int, Entity> entities) { Bag <Entity> bullets = world.GetGroupManager().getEntities("BULLETS"); Bag <Entity> ships = world.GetGroupManager().getEntities("SHIPS"); if (bullets != null && ships != null) { for (int a = 0; ships.Size() > a; a++) { Entity ship = ships.Get(a); for (int b = 0; bullets.Size() > b; b++) { Entity bullet = bullets.Get(b); if (CollisionExists(bullet, ship)) { Transform tb = transformMapper.Get(bullet); EntityFactory.CreateBulletExplosion(world, tb.GetX(), tb.GetY()).Refresh(); world.DeleteEntity(bullet); Health health = healthMapper.Get(ship); health.AddDamage(4); if (!health.IsAlive()) { Transform ts = transformMapper.Get(ship); EntityFactory.CreateShipExplosion(world, ts.GetX(), ts.GetY()).Refresh(); world.DeleteEntity(ship); break; } } } } } }
private void OnTriggerStay2D(Collider2D collision) { Health player = collision.gameObject.GetComponent <Health>(); if (player != null) { player.AddDamage(_damageOnStay); _damageOverTime += _damageOnStay; } }
private void OnCollisionEnter2D(Collision2D collision) { //_rgbd.position = new Vector2(0, 0); Health health = collision.gameObject.GetComponent <Health>(); if (health) { health.AddDamage(10); } }
private void OnTriggerEnter2D(Collider2D collision) { _damageOverTime = 0; if (collision.gameObject.tag == "Player") { Health player = collision.gameObject.GetComponent <Health>(); if (player != null) { player.AddDamage(_damageOnEnter); _damageOverTime += _damageOnEnter; } } }
public override void Process(Entity e) { Health health = healthMapper.Get(e); health.AddDamage(10); ///wasting time .... for (int i = 0; i < 1000; i++) { double x = Math.Log(i) * Math.Cos(i); x = Math.Log(i) * Math.Cos(i); x = Math.Log(i) * Math.Cos(i); x = Math.Log(i) * Math.Cos(i); } }
public void Boom() { radius = explosionSprite.size.x; //радиус взрыва равен размеру спрайта audioSource = GetComponent <AudioSource>(); audioSource.PlayOneShot(explosionSound, soundVolume); Vector2 explosionPos = transform.position; Collider2D[] colliders = Physics2D.OverlapCircleAll(explosionPos, radius); foreach (Collider2D hit in colliders) { Health health = hit.GetComponent <Health>(); if (health) { health.AddDamage(damage); } } Destroy(gameObject, 1); }
private void OnTriggerExit2D(Collider2D collision) { Health player = collision.gameObject.GetComponent <Health>(); if (player != null) { player.AddDamage(_damageOnExit); _damageOverTime += _damageOnExit; } if (_damageOverTime > 0) { Debug.Log("Damage: " + _damageOverTime); } else if (_damageOverTime < 0) { Debug.Log("Healing: " + _damageOverTime * -1); } }
private void Hit(Collider2D collision) { if (!LayerHelper.LayerInLayerMask(collision.gameObject.layer, targetLayerMask)) { return; } Health health = collision.gameObject.GetComponent <Health>(); if (health == null) { return; } if (health.health > 0) { health.AddDamage(damage); } }
public override void Process(Entity Entity) { Health Health = Entity.GetComponent <Health>(); Health.AddDamage(20); }
public void ApplayDamage(Damage damage) { Health.AddDamage(damage.Value); Status.SetStatusEffect(damage.StatusEffect, damage.Blocker); }
public virtual void Attack() { //ВОЗМОЖНО ЗДЕСЬ АНИМАЦИЯ АТАКИ playerHealth.AddDamage(damage); StartCoroutine(CoroutineAttack()); //CoroutineAttack(); }