void Start()
        {
            var playerAttack        = new PlayerAttack();
            var attackEffect        = new AttackEffect();
            var attackMotion        = new AttackMotion();
            var playerAttackManager = new PlayerAttackManager(playerAttack, attackEffect, attackMotion);

            // サブシステムの機能をカプセル化した「攻撃する」という一連の処理を行うメソッド
            playerAttackManager.Attack();

            // サブシステムの個々のメソッドもアクセスはできる
            playerAttack.Attack();
            attackEffect.ShowAttackEffect();
            attackMotion.PlayAttackMotion();
        }
Exemplo n.º 2
0
    public void Attack()
    {
        if (attackmotion == AttackMotion.LEFT)
        {
            animator.SetTrigger("AttackLeft");
            swordEffectLeft.Play();
            attackmotion = AttackMotion.RIGHT;
        }
        else
        {
            animator.SetTrigger("AttackRight");
            swordEffectRight.Play();
            attackmotion = AttackMotion.LEFT;
        }
        canattack = false;

        CancelInvoke("ResetCanAttack");
        Invoke("ResetCanAttack", attackingtime + 1);
    }
Exemplo n.º 3
0
    public void Attack()
    {
        if (!canAttack)
        {
            return;
        }

        //受击时,不能攻击
        if (hitingTime > 0)
        {
            return;
        }

        //攻击动作一左一右
        if (attackMotion == AttackMotion.Left)
        {
            animator.SetTrigger("AttackLeft");
            swordEffectLeft.Play();
            attackMotion = AttackMotion.Right;
        }
        else
        {
            animator.SetTrigger("AttackRight");
            swordEffectRight.Play();
            attackMotion = AttackMotion.Left;
        }

        AudioSource.PlayClipAtPoint(swordSound, transform.position, 1);
        attackingTime = AttackTime;

        //刚攻击完,不能立即攻击
        canAttack = false;

        // attackingTime + 1 秒后,重置为可攻击状态
        CancelInvoke("ResetCanAttack");
        Invoke("ResetCanAttack", attackingTime + 1);
    }
    private void AttackControl()
    {
        if (!isPlayable)
        {
            return;
        }

        if (attackTimer > 0.0f)
        {
            // Attacking
            attackTimer -= Time.deltaTime;
            if (attackTimer <= 0)
            {
                attackCollider.SetPowered(false);
            }
        }
        else if (attackDisableTimer <= 0.0f)
        {
            if (IsAttacking())
            {
                attackCollider.SetPowered(true);
                attackTimer        = AttackTime;
                attackDisableTimer = AttackDisableTime;

                animator.SetTrigger(animationTriggers[(int)attackMotion]);
                attackMotion = (AttackMotion)(((int)attackMotion + 1) % 2);

                attackVoiceAudio.PlayOneShot(attackSounds[attackSoundIndex]);
                attackSoundIndex = (attackSoundIndex + 1) % attackSounds.Length;
                swordAudio.PlayOneShot(swordSound);
            }
        }
        else
        {
            attackDisableTimer -= Time.deltaTime;
        }
    }
Exemplo n.º 5
0
 public void StopAttack()
 {
     AttackBox.enabled   = false;
     CurrentAttackMotion = null;
     IsAttacking         = false;
 }
Exemplo n.º 6
0
 public void Attack()
 {
     AttackBox.enabled   = true;
     CurrentAttackMotion = new Kick(Force, KnockbackTime);
     IsAttacking         = true;
 }
Exemplo n.º 7
0
 public void Attack(AttackMotion _attackMotion)
 {
     AttackBox.enabled   = true;
     CurrentAttackMotion = _attackMotion;
     IsAttacking         = true;
 }
Exemplo n.º 8
0
 public PlayerAttackManager(PlayerAttack playerAttack, AttackEffect attackEffect, AttackMotion attackMotion)
 {
     _playerAttack = playerAttack;
     _attackEffect = attackEffect;
     _attackMotion = attackMotion;
 }