Пример #1
0
    void Update()
    {
        _damageCooldown.AddRemainingSeconds(-Time.deltaTime);

        var color = spriteRenderer.color;

        if (_damageCooldown.CanUse())
        {
            color.a = 1;
        }
        else
        {
            var time = Time.time % 0.25f;
            color.a = time / 0.125f > 0.5f ? 0.5f : 1f;
        }

        spriteRenderer.color = color;
    }
Пример #2
0
    /// <summary>
    /// Make an attack on all game objects between the game object that has this component
    /// and the vector it is aiming to inside a range that has no obstacle between both.
    /// </summary>
    /// <param name="direction">The vector director the game object is aiming to. Must be normalized</param>
    public void MakeAttack(Vector2 direction)
    {
        if (!cooldown.CanUse())
        {
            return;
        }
        sounds.PlayEffect(sounds.meleeAttack);
        AttackAnimator();
        var targets = FindGameObjects(direction);

        foreach (var target in targets)
        {
            target.OnAttack(damage);
        }

//if UNITY_EDITOR
        var hit = targets.Count > 0;

        Debug.DrawRay(transform.position, direction * range, hit ? Color.green : Color.red);
//#endif
    }
Пример #3
0
 protected bool CanShoot()
 {
     return(cooldown.CanUse());
 }