예제 #1
0
    public override void PlayVocal(VocalType vocalType)
    {
        if (vocalType == VocalType.Surprise)
        {
            if (UnityEngine.Random.value > 0f)
            {
                int choice = UnityEngine.Random.Range(1, 4);
                CharacterAudio.PlayOneShot(GameManager.Inst.SoundManager.GetClip(MyReference.VocalSet.ToString() + "_surprise" + choice), 0.5f);
            }
        }

        if (vocalType == VocalType.Injury)
        {
            if (UnityEngine.Random.value > 0f)
            {
                int choice = UnityEngine.Random.Range(1, 4);
                CharacterAudio.PlayOneShot(GameManager.Inst.SoundManager.GetClip(MyReference.VocalSet.ToString() + "_injury" + choice), 0.6f);
            }
        }

        if (vocalType == VocalType.Death)
        {
            if (UnityEngine.Random.value > 0f)
            {
                int choice = UnityEngine.Random.Range(1, 4);
                CharacterAudio.PlayOneShot(GameManager.Inst.SoundManager.GetClip(MyReference.VocalSet.ToString() + "_death" + choice), 0.6f);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 检测范围并攻击
    /// </summary>
    private void SlashAndDetect(CharacterAttack.AttackType attackType)
    {
        List <Collider2D> colliders = new List <Collider2D>();

        attacker.Play(attackType, ref colliders);
        bool hasEnemy     = false;
        bool hasDamageAll = false;

        // 检测是否攻击到敌人
        foreach (Collider2D c in colliders)
        {
            if (c.gameObject.layer == LayerMask.NameToLayer("Enemy Detector"))
            {
                hasEnemy = true;
                break;
            }
        }
        // 检测是否攻击到陷阱
        foreach (Collider2D c in colliders)
        {
            if (c.gameObject.layer == LayerMask.NameToLayer("Damage All"))
            {
                hasDamageAll = true;
                break;
            }
        }
        if (hasEnemy)
        {
            if (attackType == CharacterAttack.AttackType.DownSlash)
            {
                AddDownRecoilForce();
            }
            else
            {
                StartCoroutine(AddRecoilForce());
            }
        }
        if (hasDamageAll)
        {
            if (attackType == CharacterAttack.AttackType.DownSlash)
            {
                audioEffectPlayer.PlayOneShot(CharacterAudio.AudioClipType.SwordHitReject);
                AddDownRecoilForce();
            }
        }
        foreach (Collider2D col in colliders)
        {
            Breakable breakable = col.GetComponent <Breakable>();
            if (breakable != null)
            {
                breakable.Hurt(slashDamage, transform);
            }
        }
    }