Ejemplo n.º 1
0
        public void PlayAnimation_BlockImpact(float damagePoint, float damageThreshold, Status baseStatus, ref Status currentStatus)
        {
            if (!isBlocking)
            {
                return;
            }

            var staminaAfterReduction = currentStatus.ST - damagePoint;

            currentStatus.ST -= damagePoint;
            if (currentStatus.ST <= 0)
            {
                currentStatus.ST = 0;
            }

            if (staminaAfterReduction < 0)
            {
                currentStatus.HP -= Mathf.Abs(staminaAfterReduction);
            }

            FlameSword.InstantiateParrySE();
            SwordParryEffect.InstantiateEffect(ControlManager.controlTransforms.attackCollider.GetComponent <BoxCollider>());

            if (damageThreshold > baseStatus.HP * 0.65f)
            {
                animator.CrossFade(hitAnimationNameAir, .1f);
                CameraBattle.mInstance.StartCameraShake(2);
                isTakingHit = true;
                blockCounterTimer.Reset();
                blockCounterTimer.Stop();
            }
            else if (damageThreshold > (baseStatus.HP * 0.4f))
            {
                GM.GetRandomNumberWithDifferentValueFromBefore(ref randomNumber, ref currentIndex_Block, blockHeavy.Length);
                animator.CrossFade(blockHeavy[currentIndex_Block].animationName, 0.1f);
                currentBlockAnimation = blockHeavy[currentIndex_Block];
                CameraBattle.mInstance.StartCameraShake(1.5f);
                isBlockImpactBIG = true;
                isBlockImpact    = true;
                blockCounterTimer.Restart();
            }
            else
            {
                GM.GetRandomNumberWithDifferentValueFromBefore(ref randomNumber, ref currentIndex_Block, blockHeavy.Length);
                isBlockImpact = true;
                animator.CrossFade(blockLight[currentIndex_Block].animationName, 0.1f);
                currentBlockAnimation = blockHeavy[currentIndex_Block];
                CameraBattle.mInstance.StartCameraShake(0.5f);
                blockCounterTimer.Restart();
            }

            if (CameraBattle.mInstance.targetTransforms.Count == 0 && lastEnemyAttackedYou != null)
            {
                var directionTowardEnemy = (lastEnemyAttackedYou.position - GM.playerPosition).normalized;
                directionTowardEnemy.y = 0;
                ControlManager.controlTransforms.player.rotation = Quaternion.LookRotation(directionTowardEnemy);
                temporaryTarget = lastEnemyAttackedYou;
            }
        }
Ejemplo n.º 2
0
        public void TakeDamageFromAttacker(float damagePoint)
        {
            if (isDeath || isTakingDamageBIG || isBlockImpactAIR)
            {
                return;
            }
            Damage.InstantiateDamage(damagePoint, transform.position + Vector3.up);
            if (isLastBoss)
            {
                (brain as AI_LastBoss).TakeDamageFromPlayer();
            }

            isUsingSpecialAttack = false;
            isAttacking          = false;
            animator.Play("ATTACKSTOP");

            damageThreshold += damagePoint;
            bool reCheck = false;

DestinationFromBlockToDirectDamage_BecausePlayerAttackedFromBehindOrSide:

            if (isBlocking && !reCheck)
            {
                if (Mathf.Abs(GM.GetAngleBetweenMeAndPlayer(transform)) > 105)
                {
                    reCheck = true;
                    goto DestinationFromBlockToDirectDamage_BecausePlayerAttackedFromBehindOrSide;
                }

                Tamana.FlameSword.InstantiateParrySE();
                SwordParryEffect.InstantiateEffect(aiAttack.attackCollider);

                var blockThreshold = damageThreshold - (baseStatus.HP * 0.35f);
                if (blockThreshold > 0)
                {
                    currentStatus.HP -= blockThreshold;
                }

                if (currentStatus.HP <= 0)
                {
                    currentStatus.HP     = 0;
                    delayBeforeDestroyUI = 2.0f;
                    playerTransform      = null;
                    isDeath = true;
                    Minimap.DestroyEnemy(transform);

                    if (damageThreshold > baseStatus.HP * .5f)
                    {
                        aiDeath.PlayDeathAir();
                    }
                    else
                    {
                        aiDeath.PlayDeath();
                    }

                    goto Apply;
                }

                if (brain is AI_Strong)
                {
                    if ((brain as AI_Strong).isParryAndCounter)
                    {
                        if (damageThreshold < baseStatus.HP * 0.3f)
                        {
                            var aiStrong = (brain as AI_Strong);
                            aiStrong.PlayParryAndCounter(aiStrong.parryAndCounterEnter, aiStrong.parryAndCounterExit);
                            damageThreshold = 0;
                            return;
                        }
                    }
                }

                if (damageThreshold > baseStatus.HP * 0.3f)
                {
                    aiBlock.PlayBlockImpactAIR();
                }
                else if (damageThreshold > baseStatus.HP * 0.1f)
                {
                    aiBlock.PlayBlockImpactBIG();
                }
                else
                {
                    aiBlock.PlayBlockImpact();
                }
            }
            else // こいつをブロックしなければー
            {
                currentStatus.HP -= damagePoint;

                if (currentStatus.HP <= 0)
                {
                    currentStatus.HP     = 0;
                    delayBeforeDestroyUI = 2.0f;
                    playerTransform      = null;
                    isDeath = true;
                    Minimap.DestroyEnemy(transform);

                    if (damageThreshold > baseStatus.HP * .5f)
                    {
                        aiDeath.PlayDeathAir();
                    }
                    else
                    {
                        aiDeath.PlayDeath();
                    }
                }
                else
                {
                    if (isLastBoss && (brain as AI_LastBoss).isTakingBigDamage)
                    {
                    }
                    else
                    {
                        if (damageThreshold > baseStatus.HP * .5f)
                        {
                            isTakingDamageBIG = true;
                            isBlocking        = false;
                            HitAnimation.mInstance.PlayAir(animator, ref currentHitAnimationName, takingHitComparator);
                        }
                        else if (damageThreshold > baseStatus.HP * .3f)
                        {
                            isTakingDamage = true;
                            HitAnimation.mInstance.PlayHeavy(animator, ref currentHitAnimationName, takingHitComparator);
                        }
                        else
                        {
                            isTakingDamage = true;
                            HitAnimation.mInstance.PlayLight(animator, ref currentHitAnimationName, takingHitComparator);
                        }
                    }
                }
            }

Apply:

            if (isAttacking)
            {
                isAttacking = false;
            }
            animator.SetLayerWeight(animator.GetLayerIndex("Attack"), 0.0f);

            enemyHP_Delay.fillAmount = currentStatus.HP / baseStatus.HP;

            delayHP    = 1.5f;
            updatingHP = true;
        }