Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
            {
                PopulateModules();
            }
            else
            {
#endif
            EnemySpawn[] spawns = UnityEngine.Object.FindObjectsOfType <EnemySpawn>();
            for (int i = 0; i < spawns.Length; i++)
            {
                int        index = GetWeightedRandomIndex(meshes);
                GameObject enemy = Instantiate(meshes[index].prefab, spawns[i].transform.position, spawns[i].transform.rotation) as GameObject;
                //enemy.transform.localScale = new Vector3(2,2,2);
                if (enemy == null)
                {
                    continue;
                }
                index = GetWeightedRandomIndex(aims);
                enemy.AddComponent(Type.GetType(aims[index].className));

                index = GetWeightedRandomIndex(attacks);
                AttackModule attackmodule = enemy.AddComponent(Type.GetType(attacks[index].className)) as AttackModule;
                attackmodule.weapon     = attacks[index].weapon;
                attackmodule.projectile = attacks[index].projectile;
                enemy.GetComponent <Animator>().runtimeAnimatorController = attacks[index].anim;

                index = GetWeightedRandomIndex(moves);
                enemy.AddComponent(Type.GetType(moves[index].className));

                index = GetWeightedRandomIndex(specials);
                enemy.AddComponent(Type.GetType(specials[index].className));

                Enemy E = enemy.AddComponent <Enemy>();
                if (dizzyEffect != null)
                {
                    E.deathEffect = dizzyEffect;
                }
            }
#if UNITY_EDITOR
        }
#endif
        }
Ejemplo n.º 3
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>();
        }