示例#1
0
    public void Update(float deltaTime, PlayerInputScript player)
    {
        AttackTimer += deltaTime;
        player.UpdateAttackInputVariables(AttackTimer >= blockAttackInputTime, AttackTimer > -blockNewAttackTime);
        if (!hasDamaged && AttackTimer >= damageTime)
        {
            Collider2D[] hits = player.ThrowAttack(attackPosition, attackSize);
            foreach (Collider2D hit in hits)
            {
                HealthComponent healthComponent = hit.GetComponent <HealthComponent>();
                if (healthComponent != null)
                {
                    healthComponent.Damage(damage, Vector2.zero);
                }
                EnemyHand enemyHand = hit.GetComponent <EnemyHand>();
                if (enemyHand != null)
                {
                    //Debug.Log("Test");
                    enemyHand.Damage(damage);
                }
            }
            hasDamaged = true;
        }

        if (AttackTimer >= attackLength)
        {
            player.EndAttack();
        }
    }