Example #1
0
        public override void TakeDamage(int damage, DamageType damageType)
        {
            if (!enabled)
            {
                return;
            }
            health = Mathf.Clamp(health - damage, 0, maxHealth);
            if (damage > 0)
            {
                rampingDown = true;
                rampValue   = 1;
            }
            if (health <= 0)
            {
                GameManager.GM.enemyKills++;
                Transform deathBone = transform.Find("hero_root/hero_spine_1/hero_spine_2/hero_head");
                if (deathEffect != null)
                {
                    Transform deathT = (Instantiate(deathEffect, deathBone.position, deathBone.rotation) as GameObject).transform;
                    deathT.parent        = deathBone;
                    deathT.localPosition = Vector3.zero;
                }
                attackMod.Death(damageType);
                moveMod.Death(damageType);
                aimMod.Death(damageType);
                specialMod.Death(damageType);

                attackMod.enabled  = false;
                moveMod.enabled    = false;
                aimMod.enabled     = false;
                specialMod.enabled = false;

                attackMod  = null;
                moveMod    = null;
                aimMod     = null;
                specialMod = null;
                anim.SetTrigger("Death");
                CharacterController enemyController = GetComponent <CharacterController>();
                Rigidbody           enemyRigid      = GetComponent <Rigidbody>();
                Destroy(enemyController);
                Destroy(enemyRigid);
                enabled = false;

                //Destroy(gameObject);
            }
        }
Example #2
0
        public virtual void Awake()
        {
            anim       = GetComponent <Animator>();
            attackMod  = GetComponent <AttackModule>();
            moveMod    = GetComponent <MovementModule>();
            aimMod     = GetComponent <AimModule>();
            specialMod = GetComponent <SpecialModule>();

            renderers = GetComponentsInChildren <Renderer>();
            maxHealth = (health > 0) ? health : 1;

            aimMod.Init();
            attackMod.Init();
            moveMod.Init();
            specialMod.Init();

            //HCC = GameObject.FindGameObjectWithTag("Player").GetComponent<HeroCharacterController>();
            FM = Camera.main.GetComponent <FocusMode>();
        }