예제 #1
0
        private void Awake()
        {
            spiritBombState = GetComponentInChildren <SpiritBomb>();
            moveState       = GetComponentInChildren <MoveState>();
            fleeState       = GetComponentInChildren <FleeState>();
            idleState       = GetComponentInChildren <IdleState>();
            deathState      = GetComponentInChildren <DeathState>();
            hailState       = GetComponentInChildren <HailAttack>();
            syphonState     = GetComponentInChildren <PowerSyphonState>();

            CharacterBase[] characters = FindObjectsOfType <CharacterBase>();

            foreach (CharacterBase c in characters)
            {
                if (c.gameObject.GetComponent <Kennith_Model>() != null)
                {
                    continue;
                }

                if (c.GetComponent <Health>() == null)
                {
                    return;
                }

                c.GetComponentInChildren <Health>().OnDeathEvent += RemoveEnemy;
                enemies.Add(c.gameObject);
            }

            spawners.AddRange(FindObjectsOfType <Spawner>());

            foreach (Spawner s in spawners)
            {
                s.OnSpawnedNewGameObject += AddNewEnemy;
            }

            GetComponent <Health>().OnDeathEvent += Perish;
            ShareYourPower += SyphoningPower;
        }
예제 #2
0
        private void OnDeath()
        {
            ShareYourPower -= SyphoningPower;


            // Still f****d, fix me

            for (var i = enemies.Count - 1; i > -1; i--)
            {
                if (enemies[i] != null)
                {
                    enemies[i].GetComponentInChildren <Health>().OnDeathEvent -= RemoveEnemy;
                }
            }

            for (var i = spawners.Count - 1; i > -1; i--)
            {
                if (spawners[i] != null)
                {
                    spawners[i].GetComponent <Spawner>().OnSpawnedNewGameObject -= AddNewEnemy;
                }
            }
        }