Пример #1
0
    private void OnCollisionEnter2D(Collision2D col)
    {
        //Debug.Log(col.gameObject.transform.name);
        if (col.gameObject.transform.name == "Player")
        {
            // получаем здоровье игрока
            var health = GameManager.Instance.healthContainer[col.gameObject];
            health.takeHit(damage);

            PlatformerTools.ShowHealthBar(col.gameObject);
        }
    }
Пример #2
0
    public void SetDamage()
    {
        if (health != null)
        {
            health.takeHit(damage);

            if (health.HealthCount > 0 && collisionObject)
            {
                PlatformerTools.ShowHealthBar(collisionObject);
            }
        }
        collisionObject = null;
        health          = null;
    }
Пример #3
0
    private void OnCollisionEnter2D(Collision2D col)
    {
        if (GameManager.Instance.healthContainer.ContainsKey(col.gameObject))
        {
            health = GameManager.Instance.healthContainer[col.gameObject];

            health.takeHit(damage);

            //Если есть еще хп, показываем хелсбар
            if (health.HealthCount > 0)
            {
                PlatformerTools.ShowHealthBar(col.gameObject);
            }
        }
    }