示例#1
0
        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;
                            }
                        }
                    }
                }
            }
        }
示例#2
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        Health player = collision.gameObject.GetComponent <Health>();

        if (player != null)
        {
            player.AddDamage(_damageOnStay);
            _damageOverTime += _damageOnStay;
        }
    }
示例#3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        //_rgbd.position = new Vector2(0, 0);
        Health health = collision.gameObject.GetComponent <Health>();

        if (health)
        {
            health.AddDamage(10);
        }
    }
示例#4
0
 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;
         }
     }
 }
示例#5
0
        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);
            }
        }
示例#6
0
    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);
    }
示例#7
0
    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);
        }
    }
示例#8
0
        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);
        }
示例#10
0
 public void ApplayDamage(Damage damage)
 {
     Health.AddDamage(damage.Value);
     Status.SetStatusEffect(damage.StatusEffect, damage.Blocker);
 }
示例#11
0
 public virtual void Attack()
 {
     //ВОЗМОЖНО ЗДЕСЬ АНИМАЦИЯ АТАКИ
     playerHealth.AddDamage(damage);
     StartCoroutine(CoroutineAttack()); //CoroutineAttack();
 }