Exemplo n.º 1
0
    /// <summary>
    /// 技能使用(詠唱後)
    /// </summary>
    public virtual void UseSkill()
    {
        if (soundControl != null && inUsingSound != null)
        {
            soundControl.PlaySound(inUsingSound);
        }
        if (anim != null)
        {
            AnimationBase.Instance.PlayAnimationLoop(anim, skillAnimTrigger, currentSkill.duration, false, false);
        }
        if (inUsingParticle != null)
        {
            inUsingParticle.Play(true);
        }

        // 啟用技能
        SetSkillCollisionEnable(true);

        // 觸發立即性效果
        InvokeAffect(immediatelyAffect);
        InvokeAffect(currentSkill.immediatelyEvent);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 技能於物件池中生成至畫面時(尚未開始詠唱與使用前)
    /// </summary>
    public virtual void GenerateSkill(Character character, Skill skill)
    {
        sourceCaster = character;
        currentSkill = skill;

        anim         = GetComponent <Animator>();
        soundControl = sourceCaster.opsc;

        // Active
        this.gameObject.SetActive(true);
        // 禁用技能Hitbox與貼圖 (避免生成技能時直接播放動畫與觸發效果)
        SetSkillCollisionEnable(false);

        if (soundControl != null && inRenderSound != null)
        {
            soundControl.PlaySound(inRenderSound);
        }
    }
Exemplo n.º 3
0
    private IEnumerator StartTrueAttack(Action <OperationStateType> setOperationState, Action <float> setDelay, AttackType attackType = AttackType.Attack, ElementType elementType = ElementType.None)
    {
        /// 攻擊前搖
        opc.isPreAttacking = true;

        _attack.AttackOperationLock();

        // 重置每段攻擊時間間隔
        AttackAnimNumber++;
        ResetAttackDelayDuration();
        setDelay(attackDelayDuration);

        // 若是最後一段的攻擊動作,就無法預存下一個攻擊動作。
        if (CheckIsFinalAttack())
        {
            setOperationState(OperationStateType.Interrupt);
        }
        else
        {
            setOperationState(OperationStateType.Trigger);
        }
        yield return(new WaitForSeconds(GetFrameTimeOffset(1)));   // 等待一幀,使動畫開始撥放,否則會取到上一個動畫的狀態。

        // 攻速過快,動畫時間縮短
        preAttackAnimDuration = AnimationBase.Instance.GetCurrentAnimationLength(anim);
        if (maxAttackAnimDuration < preAttackAnimDuration)
        {
            preAttackAnimDuration = maxAttackAnimDuration;
        }
        yield return(new WaitForSeconds(preAttackAnimDuration));    // 等待動畫播放結束

        /// 攻擊中
        opc.isPreAttacking = false;
        opc.isAttacking    = true;

        // 鎖定跳躍與閃避、方向
        jump.Lock(LockType.Operation);
        evade.Lock(LockType.Operation);
        freeDirection.Lock(LockType.Operation);

        if (!CheckIsFinalAttack())
        {
            setOperationState(OperationStateType.Continuous);
        }
        else
        {
            setOperationState(OperationStateType.None);
        }
        yield return(new WaitForSeconds(GetFrameTimeOffset(2)));

        // 累積攻擊次數+1
        attackComboCount++;

        // 攻擊觸發
        opsc.PlaySound(opsc.attackSound);
        if (combatController.Attack(attackType, elementType))
        {
            opsc.PlaySound(opsc.hitSound);
        }

        // 攻速過快,動畫時間縮短
        attackAnimDuration = AnimationBase.Instance.GetCurrentAnimationLength(anim);
        if (maxAttackAnimDuration < attackAnimDuration)
        {
            attackAnimDuration = maxAttackAnimDuration;
        }

        // 儲存下次攻擊重置時間
        attackFinishedTime  = Time.time + attackAnimDuration;
        nextAttackResetTime = attackFinishedTime + attackResetDuration;

        float comboDuration = GetFrameTimeOffset(8);

        yield return(new WaitForSeconds(attackAnimDuration - comboDuration));

        // 攻擊收尾,可連段
        setOperationState(OperationStateType.Link);

        yield return(new WaitForSeconds(comboDuration));

        opc.isAttacking = false;
    }