Пример #1
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.gameObject.tag.Substring(0, 4) == "Gato")
     {
         AllCatsBehaviour allCats = col.gameObject.GetComponent <AllCatsBehaviour> ();
         if (col.gameObject.tag.Substring(4) == "Nadador")
         {
             allCats.Rigid.AddRelativeForce(new Vector2(0f, force), ForceMode2D.Force);
         }
         else
         {
             _time += Time.deltaTime;
             if (_time > 1 / hitRate)
             {
                 allCats.Hit(damage);
                 _time = 0f;
             }
         }
     }
 }
    void Scratching()
    {
        AllCatsBehaviour allCats = GetComponentInParent <AllCatsBehaviour>();

        allCats.an.SetBool("Parede", allCats.onWall);
        if (allCats.onWall)
        {
            allCats.Rigid.velocity = Vector2.zero;
            audioS.enabled         = true;
            audioS.loop            = true;
            if (!audioS.isPlaying)
            {
                audioS.Play();
            }
        }
        else
        {
            audioS.enabled = false;
            audioS.loop    = false;
        }
    }
Пример #3
0
    void Attack()
    {
        AllCatsBehaviour allCats = GetComponentInParent <AllCatsBehaviour>();

        if (Input.GetKeyDown(KeyCode.Space) && _time > attackTime && CatSwitchScript.Instance.canBruxoAttack)
        {
            if (Atk != null)
            {
                Destroy(Atk);
            }
            attacking = true;
            allCats.an.SetTrigger("Atacando");
            _time = 0f;
        }
        if (attacking)
        {
            _time += Time.deltaTime;
            if (_time >= attackDelay)
            {
                SoundEffectsScript.Instance.MakeFireCastingSound();
                Atk = Instantiate(AttackObject, (Vector3)allCats.Rigid.position + transform.up, transform.rotation);
                PlayerAttackBehaviour a = Atk.GetComponent <PlayerAttackBehaviour>();
                a.setSpeed(attackSpeed);
                _time     = 0f;
                attacking = false;
            }
        }
        else
        {
            _time += Time.deltaTime;
            if (Atk != null && _time > attackTime)
            {
                Destroy(Atk);
            }
        }
    }