Exemplo n.º 1
0
    private bool AttackTarget(IAttackable player, bool damageOnDraw = false)
    {
        InCombat    = true;
        actionTimer = attackAnimationTime;
        Lock();

        Equipment.ShowWeapon();

        var weapon     = Inventory.GetEquipmentOfCategory(ItemCategory.Weapon);
        var weaponAnim = weapon?.Type.GetAnimation() ?? 0;

        if (!playerAnimations.IsAttacking() || lastTrainedSkill != Skill.Fighting)
        {
            lastTrainedSkill = Skill.Fighting;
            playerAnimations.StartCombat(weaponAnim);
            if (!damageOnDraw)
            {
                return(true);
            }
        }

        playerAnimations.Attack(weaponAnim);

        transform.LookAt(player.Transform);
        StartCoroutine(DamageEnemy(player));
        return(true);
    }
Exemplo n.º 2
0
 private void DoAttack()
 {
     if (!CanAttack || !animationController)
     {
         return;
     }
     animationController.Attack();
     nextAttackTime = Time.time + 0.5f;
 }
Exemplo n.º 3
0
    public void Attack()
    {
        if (Time.time >= nextAttackTime)
        {
            controller.Attack(); //animation

            PlaySound("hit1", "hit2");


            Collider2D hitEnemies = Physics2D.OverlapCircle(attackPoint.position, attackRange, enemyLayers);

            if (hitEnemies != null)
            {
                enemyColllider = hitEnemies;
                //Debug.Log("enemy -40" + hitEnemies.name);
                StartCoroutine("DelayedAttack", 0.4f);
            }



            nextAttackTime = Time.time + 1f / attackRate;
        }
    }