Beispiel #1
0
    void shooting( )
    {
        Vector3 diff = _player.transform.position - transform.position;

        _rb.velocity = diff.normalized * 0;

        _shot_time += Time.deltaTime;

        if (_shot_time >= 1 && !_shot)
        {
            _sound.playSE("shoter_attack");
            //SE_e_shooterAttack.Play();
            Instantiate(_bullet, transform.position, Quaternion.identity);
            _shot = true;
        }

        if (_shot_time >= 2)
        {
            _state = STAET.STATE_MOVE;
            //_anim.SetBool( "walk", true );
            _shot_time = 0;
            _shot      = false;
        }
    }
Beispiel #2
0
    void attack( )
    {
        _sound.playSE("sword_attack");
        //SE_e_nearAttack.Play();

        _attack_count += Time.deltaTime;
        _rb.velocity   = Vector2.zero;

        if (_state == STATE.STATE_ATTACK &&
            _attack_count > _anim.GetCurrentAnimatorStateInfo(0).length)
        {
            Vector2 distance = _player.transform.position - transform.position;
            if (distance.magnitude < ATTCK_RANGE)
            {
                _player.GetComponent <plyaer> ().damage(POWER);
            }
            _state = STATE.STATE_MOVE;
            _anim.SetBool("attack", false);
            _attack_count = 0.0f;
        }
    }