Exemplo n.º 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);
        }
    }
Exemplo n.º 2
0
    public void SetDamage()
    {
        if (health != null)
        {
            health.takeHit(damage);

            if (health.HealthCount > 0 && collisionObject)
            {
                PlatformerTools.ShowHealthBar(collisionObject);
            }
        }
        collisionObject = null;
        health          = null;
    }
Exemplo n.º 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);
            }
        }
    }