Пример #1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            DamageDisplayer item = null;

            for (int i = 0; i < _ex_animations.Count; i++)
            {
                if (!_ex_animations[i]._isvalid)
                {
                    _ex_animations.RemoveAt(i);
                    i--;
                }
                else
                {
                    _ex_animations[i].Draw(spriteBatch);
                }
            }
            for (int i = 0; i < _damage_positioins.Count; i++)
            {
                item = _damage_positioins[i];
                if (item.Counter == 0)
                {
                    _damage_positioins.RemoveAt(i);
                    i--;
                }
                else
                {
                    spriteBatch.DrawString(_damage_font, $"- {item.Damage}", item.Position, Color.Red);
                    item.Counter--;
                }
            }
        }
Пример #2
0
    internal void TakeDamages(int damages, PlayerBehaviour player)
    {
        _target = player;

        Lifepoints = Mathf.Clamp(Lifepoints - damages, 0, MaxLifepoints);
        DamageDisplayer.ShowDamage(
            damages,
            transform.position + Vector3.up * 2,
            new Color(211f / 255, 84f / 255, 0)
            );

        if (Lifepoints > 0)
        {
            Collider[] cols = Physics.OverlapSphere(transform.position, CallEnemyRange, ~LayerMask.NameToLayer("Enemy"));
            if (cols.Length > 0)
            {
                foreach (Collider col in cols)
                {
                    if (col.gameObject.TryGetComponent(out EnemyBehaviour enemy))
                    {
                        enemy.SetTarget(player);
                    }
                }
            }
        }
    }
    internal void TakeDamages(int damages)
    {
        _lifeCooldown = 0;
        Lifepoints    = Mathf.Clamp(Lifepoints - damages, 0, MaxLifepoints);

        DamageDisplayer.ShowDamage(
            damages,
            transform.position + Vector3.up * 2,
            new Color(142f / 255, 68f / 255, 173f / 255)
            );
    }
 private void Awake()
 {
     Instance = this;
 }