Exemple #1
0
        public void StartBlock()
        {
            if (isBlocking || isShieldInCooldown)
            {
                return;
            }
            isBlocking = true;
            OnBlockStarted();
            managerUI.ActivateActionSlider(shieldTimeLimit, SliderType.STATE_CASTING, true);
            shieldTimerCoroutine = ShieldCastTimer();
            StartCoroutine(shieldTimerCoroutine);
            IEnumerable <IEnemy> enemies = FindObjectsOfType <MonoBehaviour>().OfType <IEnemy>();

            foreach (IEnemy enemy in enemies)
            {
                enemy.ActivatedPlayerShield(true);
            }
            animator.SetBool("Block", true);
            Transform paticleTransform = this.transform.Find("ShieldCenter").transform;

            shieldCenter.GetComponent <SphereCollider>().enabled = true;
            shieldParticle       = Instantiate(shieldParticlePrefab, paticleTransform);
            secondShieldParticle = Instantiate(secondShieldParticlePrefab, paticleTransform);
            Collider[] enemiesInShieldRange = Physics.OverlapSphere(this.transform.position, shieldParticle.transform.localScale.x);
            foreach (Collider enemy in enemiesInShieldRange)
            {
                if (enemy.gameObject.CompareTag("Enemy"))
                {
                    enemy.gameObject.GetComponent <EnemyBehaviorAI>().SetHitVelocity(-enemy.transform.forward, 5);
                    enemy.gameObject.GetComponent <Health>().DecreaseHealth(0f);
                }
            }
        }