Exemple #1
0
        private void DoDamage(AttackAnimationSetting attackAnimationSetting)
        {
            var cols = Physics.OverlapSphere(ControlManager.controlTransforms.attackCollider.position, .5f, LayerMask.GetMask("Enemy"));

            if (cols.Length == 0)
            {
                return;
            }

            for (int x = 0; x < cols.Length; x++)
            {
                var baseAI = cols[x].GetComponent <Tamana.AI.BaseAI>();
                baseAI.TakeDamageFromAttacker(PlayerInfo.mInstance.baseStatus.AT * attackAnimationSetting.attackMultiplier);
                GM.isBattling = true;
                CameraBattle.updateNearestEnemyTimer = 0.0f;
                if (baseAI.isDeath && (CameraBattle.mInstance.targetTransforms.Count > 0 || temporaryTarget != null))
                {
                    if (CameraBattle.mInstance.targetTransforms.Count > 0)
                    {
                        CameraBattle.mInstance.LookForEnemy();
                    }
                    if (temporaryTarget != null)
                    {
                        temporaryTarget = GM.GetNearestEnemy(9.0f, ControlManager.controlTransforms.player.position);
                    }
                    if (temporaryTarget == null)
                    {
                        GM.isBattling = false;
                    }
                }
            }
        }
Exemple #2
0
        public void LookFor(string animationName, ref PlayerControl.AttackAnimationSetting target)
        {
            for (int i = 0; i < animations.Length; i++)
            {
                if (animationName == animations[i].animationName)
                {
                    target = animations[i];
                    return;
                }
            }

            Debug.Log("Couldn't find target animation");
        }
Exemple #3
0
        //========================================================================================================================//
        //   A N I M A T I O N     T R I G G E R S                                                                                //
        //========================================================================================================================//
        private void PlayAttackAnimation(AttackAnimationSetting[] attackArray, ref bool isCanAttack)
        {
            if (isUsingSuperStrongAttack)
            {
                return;
            }

            GM.GetRandomNumberWithDifferentValueFromBefore(ref randomNumber, ref currentIndex_Attack, attackArray.Length);

            ControlManager.playerInfo.StaminaManipulator(attackArray[currentIndex_Attack].staminaCost, ref isCanAttack);
            if (isCanAttack == false)
            {
                return;
            }

            isBlocking  = false;
            isAttacking = true;

            GM.SetAnimatorLayerWeight("Attack", 1.0f);

            animator.Play(attackArray[currentIndex_Attack].animationName);
            currentAttackAnimation = attackArray[currentIndex_Attack];

            if (currentAttackAnimation.damageTiming2 != 0)
            {
                isFirstHit  = true;
                isSecondHit = true;
            }
            else
            {
                isFirstHit  = true;
                isSecondHit = false;
            }

            animationTimer      = 0;
            damaging            = true;
            isAbleToAttackAgain = false;
        }
Exemple #4
0
        private void SuperStrongAttack()
        {
            if (isDamagingSuperStrongAttack)
            {
                if (Time.time > superStrongAttackTimer)
                {
                    if (PlayerInfo.mInstance.currentStatus.ST < 50.0f)
                    {
                        currentAttackAnimation.attackMultiplier *= (PlayerInfo.mInstance.currentStatus.ST / 50.0f);
                    }
                    PlayerInfo.mInstance.StaminaManipulator(50, ref isCanAttack);
                    DoDamage(currentAttackAnimation);
                    isDamagingSuperStrongAttack = false;
                }

                return;
            }

            if (isUsingSuperStrongAttack)
            {
                // 敵から攻撃を受けた場合
                if (isTakingHit)
                {
                    isDamagingSuperStrongAttack      = false;
                    superStrongAttackSpeedMultiplier = 1.0f;
                    isUsingSuperStrongAttackSlowDown = false;
                    isUsingSuperStrongAttack         = false;
                    return;
                }

                // プレイヤーを敵方向に向かせる。
                if (CameraBattle.mInstance.targetTransforms.Count == 0 && temporaryTarget != null)
                {
                    var directionTowardEnemy = (temporaryTarget.position - ControlManager.controlTransforms.player.position).normalized;
                    directionToNearbyEnemy.y = 0;
                    var lookRotation = Quaternion.LookRotation(directionTowardEnemy);
                    var forward      = ControlManager.controlTransforms.player.forward;
                    forward.y = 0;
                    if (Vector3.Angle(forward, directionTowardEnemy) > 5.0f)
                    {
                        ControlManager.controlTransforms.player.rotation = Quaternion.Slerp(ControlManager.controlTransforms.player.rotation, lookRotation, 4.0f * Time.deltaTime);
                    }
                }

                if (Time.time > superStrongAttackTimer && !isUsingSuperStrongAttackSlowDown)
                {
                    isUsingSuperStrongAttackSlowDown = true;
                    superStrongAttackSpeedMultiplier = 0.02f;
                }

                superStrongAttackDamageMultiplier = 1.8f + (Time.time - superStrongAttackTimer);

                if (Input.GetButtonUp("Triangle") || Time.time > superAttackTimerThreshold)
                {
                    swordTrail.enabled = true;
                    StartCoroutine(SwordTrailAutoTurnOFF());
                    isUsingSuperStrongAttackSlowDown        = false;
                    isUsingSuperStrongAttack                = false;
                    superStrongAttackSpeedMultiplier        = 1.0f;
                    superStrongAttackTimer                  = Time.time + 0.15f;
                    isDamagingSuperStrongAttack             = true;
                    currentAttackAnimation.attackMultiplier = superStrongAttackDamageMultiplier;
                    FlameSword.InstantiateSwingSE();
                }

                return;
            }

            if (!isReadForSuperStrongAttack)
            {
                return;
            }
            isReadForSuperStrongAttack = Input.GetButton("Triangle");

            if (Time.time > superStrongAttackTimer)
            {
                animator.Play(superStrongAttackName);
                superStrongAttackTimer     = Time.time + superStrongAttack_SlowDown;
                isUsingSuperStrongAttack   = true;
                isReadForSuperStrongAttack = false;
                currentAttackAnimation     = superStrongAttack;
                var cols = Physics.OverlapSphere(ControlManager.controlTransforms.player.position, 9.0f, LayerMask.GetMask("Enemy"));
                temporaryTarget           = GM.GetNearestEnemy(cols, ControlManager.controlTransforms.player.position);
                superAttackTimerThreshold = Time.time + 2.1f;
            }
            else
            {
                if (Input.GetButtonUp("Triangle"))
                {
                    PlayAttackAnimation(strongAttack, ref isCanAttack);
                    FaceTowardNearestEnemyWhenAttacking();
                    isReadForSuperStrongAttack = false;
                }
            }
        }