Exemplo n.º 1
0
 bool TryAttack(Vector2 pos)
 {
     Collider2D[] colliderCollection = Physics2D.OverlapCircleAll(pos, attackRange);
     foreach (var collider in colliderCollection)
     {
         if (collider.tag == "interact")
         {
             targetAttack = collider.gameObject;
             InteractiveEntity targetAttack_ie = targetAttack.GetComponent <InteractiveEntity>();
             if (targetAttack_ie.AttackCheck())
             {
                 int           r          = Random.Range(0, 4);
                 CatAttackType attackType = CatAttackType.bite;
                 if (r < 2)
                 {
                     attackType = CatAttackType.pee;
                     animator.SetInteger("catAtkType", 2);
                 }
                 else
                 {
                     animator.SetInteger("catAtkType", r - 3);
                 }
                 CatAttack(targetAttack_ie, attackType);
                 return(true);
             }
         }
     }
     return(false);
 }
    public virtual void OnCatInteract(CatAttackType type)
    {
        total_durability -= uniform_damage;
        switch (type)
        {
        case CatAttackType.bite:
            durability -= bite_damage;
            break;

        case CatAttackType.scratch:
            durability -= scratch_damage;
            break;

        case CatAttackType.pee:
            durability -= pee_damage;
            break;

        default:
            break;
        }
        if (durability <= 0)
        {
            SEManager.Instance.PlaySE(20);

            durability = 0;
            OnTotalDamage();
        }
        else
        {
            SEManager.Instance.PlaySE(19);

            if (type == CatAttackType.pee)
            {
                AddCleaningTool();
            }
            else
            {
                AddRequiredTool();
            }
        }
        DrawUI();
        if (total_durability < 0)
        {
            SceneManager.LoadScene(2);
        }
    }
Exemplo n.º 3
0
    public override void OnCatInteract(CatAttackType type)
    {
        switch (type)
        {
        case CatAttackType.bite:
            durability -= bite_damage;
            break;

        case CatAttackType.scratch:
            durability -= scratch_damage;
            break;

        case CatAttackType.pee:
            durability -= pee_damage;
            break;

        default:
            break;
        }
        if (durability <= 0)
        {
            durability = 0;
            OnTotalDamage();
        }
        else
        {
            if (type == CatAttackType.pee)
            {
                AddCleaningTool();
                durability += 5;
                if (durability > durability_max)
                {
                    durability = durability_max;
                }
            }
            else
            {
                AddRequiredTool();
            }
        }
    }
Exemplo n.º 4
0
 void CatAttack(InteractiveEntity target, CatAttackType attackType)
 {
     target.OnCatInteract(attackType);
     state = CatState.attack;
     timer = attackTime;
 }